initial array function working with array returned, used while loop