detecting when device disconnect