Fixed attachment logic.