     /// The match object provided by GameKit.
     public var match: GKMatch!
     
+    private var achievements = [String: GKAchievement]()
     private weak var delegate: GCHelperDelegate?
     private var invite: GKInvite!
     private var invitedPlayer: GKPlayer!
-    private var playersDict = [String:AnyObject]()
+    private var playersDict = [String: AnyObject]()
     private weak var presentingViewController: UIViewController!
     
     private var authenticated = false
     private var matchStarted = false
-    
-    private var allPossibleAchievementsDict = [String:GKAchievement]()
     
     /// The shared instance of GCHelper, allowing you to access the same instance across all uses of the library.
     public class var sharedInstance: GCHelper {

    }
    
    /**
     Reports progress on an achievement to GameKit if the achievement hadn't been completed already
     
     :param: identifier A string that matches the identifier string used to create an achievement in iTunes Connect.
     :param: percent A percentage value (0 - 100) stating how far the user has progressed on the achievement.
     */
    public func reportAchievementIdentifier(identifier: String, percent: Double) {
        let achievement = GKAchievement(identifier: identifier)
        
        if (!isAchievementCompleted(identifier: identifier))
        {
            achievement.percentComplete = percent
            achievement.showsCompletionBanner = true
            GKAchievement.reportAchievements([achievement]) { (error) -> Void in
                if error != nil {
                    print("Error in reporting achievements: \(error)")
                }
            }
        }
    }
    
    
    /**
     Loads all existing achievements from GameKit and adds them to allPossibleAchievements dictionary.
     
     */
    public func loadAllPossibleAchievementsDict()
    {
        GKAchievement.loadAchievementsWithCompletionHandler({( achievements, error) in
            if (error != nil) {
                print("Error in loading achievements: \(error)")
            }
            else
                if !(achievements==nil)
                {
                    for anAchievement in achievements! {
                        self.allPossibleAchievementsDict[anAchievement.identifier!] = anAchievement                    }
            }
        })
        
    }
    
    /**
     Checks if an achievement in allPossibleAchievements is already 100% completed
     
     :param: identifier A string that matches the identifier string used to create an achievement in iTunes Connect.
     
     */
    public func isAchievementCompleted (identifier: String) -> Bool{
        
        let lookupAchievement:GKAchievement? = allPossibleAchievementsDict[identifier]
        
        if let achievement = lookupAchievement {
            if achievement.percentComplete != 100 {
                return false
            }
            return true
        }
        else {
            return false
            
        }
    }
    
    
    /**
     Resets all achievements that have been reported to GameKit.
     */
    public func resetAllAchievements() {
        GKAchievement.resetAchievementsWithCompletionHandler { (error) -> Void in
            if error != nil {
                print("Error resetting achievements: \(error)")
            }
        }
    }

        let playerIDs = match.players.map { $0.playerID } as! [String]
        
        GKPlayer.loadPlayersForIdentifiers(playerIDs) { (players, error) -> Void in
            guard error == nil else {
                print("Error retrieving player info: \(error?.localizedDescription)")
                self.matchStarted = false
                self.delegate?.matchEnded()
                return
            }
            
            guard let players = players else {
                print("Error retrieving players; returned nil")
                return
            }
            
            for player in players {
                print("Found player: \(player.alias)")
                self.playersDict[player.playerID!] = player
            }
            
            self.matchStarted = true
            GKMatchmaker.sharedMatchmaker().finishMatchmakingForMatch(self.match)
            self.delegate?.matchStarted()
        }
    }
    
