fix bug in next_between