Fix infinite loop in sync