Extract choose_first_in_range method