Working solution, still using takeWhile...