Refactor search in rotated sorted array to make it easy to remember