fixed next_hole function