search in rotated array reimpl