Refactors search