fixing timeEndReached bug