added external canonicalize method