call sync after every loop