added procedure for converting to canonical form