Refactor search method to meet spec