attach: refactoring