refactor square_searcher into smaller methods