Added a guard when calling sync.