modified removeCommandType method