Changed search mechanism

Still have some bugs probably but changed the whole search mechanism