refactored CMD.js, particularly as to how the return object is generated.