Master skeleton code for search algorithm