changed sendData helper function