Refactor search method to include case statement