[command] auto-update - refactor and move code in runCommand() method