Improved check for space in command name