code refactor of customer search/filter logic