Add isEnd() for end detection