integrated Carl's changes - no test yet