- revised to return nil with error string instead of assert