Enhance checkValidCommand