used binary search to solve an old problem