Refactor search function with get instead of post