cleans up horrific search method