code to clean up devices