Add curly braces to while loop statement.
Updata index space of return statement.