find_upper_bound better code