fix Nil device problem