seperated the sync function into little ones