Factor out search into own file