refactor buildCanonicalizedString