Search algorithm part1