fix subtle getEnd/hasEnd bug