i really need to stop messing with this search algorithm