refactor running command logic to runcmd.go