Move running command to its own function