Modified InvalidCommand for flexibility