Fix conditional order to clear canonicalCode