Refactor some search stuff

you already checked this on the line above