fixed crashing bugs when failed to open the device