Refactor search and put pagination behind a flag