refactored search bar code