 
                         moreUnreadMessages(inPage: page, withPerPage: perPage, failureHandler: { (reason, errorMessage) in
                             dispatch_group_leave(downloadGroup)
-                            }, completion: { result in
-                                if let currentPageMessages = result["messages"] as? [JSONDictionary] {
-                                    messages += currentPageMessages
-                                }
-                                dispatch_group_leave(downloadGroup)
+
+                        }, completion: { result in
+                            if let currentPageMessages = result["messages"] as? [JSONDictionary] {
+                                messages += currentPageMessages
+                            }
+
+                            dispatch_group_leave(downloadGroup)
                         })
                     }
 

                        completion(messages)
                    }
                }
        }
    }
}



func unreadMessages(completion completion: [JSONDictionary] -> Void) {

    headUnreadMessages { result in

        var messages = [JSONDictionary]()

        if let page1Messages = result["messages"] as? [JSONDictionary] {
            messages += page1Messages
        }

        if
            let count = result["count"] as? Int,
            let currentPage = result["current_page"] as? Int,
            let perPage = result["per_page"] as? Int {

                if count <= currentPage * perPage {
                    completion(messages)

                } else {
                    // We have more messages

                    let downloadGroup = dispatch_group_create()
