Refactored JS + fixed searchbar