Refactor some search stuff

is the `is not None` check necessary?