changed to passing sync as reference