added safe_sync function for tackling the doattend api bug