moved sync function