develop canonicalizing function