Relocated the VERY UGLY search function to different file