fixed bugs in attach devices