 
             var uploadImageInfos = [UploadImageInfo]()
 
+            let mediaImagesCount = mediaImages.count
+            var uploadErrorMessage: String?
+
             mediaImages.forEach({ image in
 
                 let imageWidth = image.size.width

                        defaultFailureHandler(reason, errorMessage: errorMessage)

                        dispatch_async(dispatch_get_main_queue()) {
                            dispatch_group_leave(uploadImagesGroup)
                        }


                }
            })

            dispatch_group_notify(uploadImagesGroup, dispatch_get_main_queue()) { [weak self] in

                guard uploadImageInfos.count == mediaImagesCount else {

                    YepHUD.hideActivityIndicator()
                    self?.postButton.enabled = true

                    let message = uploadErrorMessage ?? NSLocalizedString("Upload failed!", comment: "")

                    YepAlert.alertSorry(message: message, inViewController: self)

                    return
                }

                if !uploadImageInfos.isEmpty {

