added execute command function for the sake of DRY