search method rewritten