better attachment script