Implement send_cmd function