fixed sync function