modify forward_search function. fix bug when lower_neighbor = upper_neighbor