Added conditional attachment saving