Refactor GenerateCommand