fixed some bug when connect to device