Implemented TakeWhile method