The sync logic should not be done in the Search function

This decoupling keeps the sync logic only in main function.