refactoring attach functionality, removing autoAttach