correct implementation of takeWhileInclusive