minor optimization in RMQ