added takewhile function to array