Refactored printCommands