optional: rework to support nonregular types