add handling of user-specified units, plus error checking