rewrite remove inactive devices
fix build error