added while loop with array function./fixed return statement.