updated takeWhile