fix sendData fn

use globel varible to increase successful rate