Count your curly braces {}. The compiler thinks your return statement is inside the loop. Code indentation is for human eyes, the compiler ignores it.