micro optimization in search(): end must be after start