Added call to dispose on attachment and refactored for reuse
Added call to dispose on attachment and refactored for reuse