Pulling out getting attachments to function