improved search alogorithim