 
 func downloadAttachmentOfMessage(message: Message) {
 
-    func updateMessage(message: Message, withAttachmentFileName attachmentFileName: String) {
+    func updateAttachmentOfMessage(message: Message, withAttachmentFileName attachmentFileName: String) {
         let realm = message.realm
         realm.beginWriteTransaction()
         message.localAttachmentName = attachmentFileName

            }
        }
    }
}

func syncFriendshipsAndDoFurtherAction(furtherAction: () -> Void) {

                        switch message.mediaType {
                        case MessageMediaType.Image.rawValue:
                            if let fileURL = NSFileManager.saveMessageImageData(data, withName: fileName) {
                                updateAttachmentOfMessage(message, withAttachmentFileName: fileName)
                            }

                        case MessageMediaType.Video.rawValue:
                            if let fileURL = NSFileManager.saveMessageVideoData(data, withName: fileName) {
                                updateAttachmentOfMessage(message, withAttachmentFileName: fileName)
                            }

                        case MessageMediaType.Audio.rawValue:
                            if let fileURL = NSFileManager.saveMessageAudioData(data, withName: fileName) {
                                updateAttachmentOfMessage(message, withAttachmentFileName: fileName)
                            }
                            
                        default:
