Converted search function to objects rather than arrays