Updated execute command function