refactored search into function and added after key up event