Using lock for getting attachments