Refactored search filtering code into promises