bug fix to canonicalization