fixed return array values for while loop and array function.