Divided sync into smaller functions