Refactor some search stuff

good catch