fixed logic bug preventing sync in some circumstances