attachment: refactoring bug fix