refactored search page to be stateful