extract sync func to sync.js