function resolveChallenge(bytes32 _listingHash) private {
        bytes32 listingHashHash = _listingHash;
        uint challengeID = listings[listingHashHash].challengeID;

        
        
        uint reward = determineReward(challengeID);

        
        bool wasWhitelisted = isWhitelisted(_listingHash);

        
        if (voting.isPassed(challengeID)) {
            whitelistApplication(_listingHash);
            
            listings[listingHashHash].unstakedDeposit += reward;

            _ChallengeFailed(challengeID);
            if (!wasWhitelisted) { _NewListingWhitelisted(_listingHash); }
        }
        
        else {
            resetListing(_listingHash);
            
            require(token.transfer(challenges[challengeID].challenger, reward));

            _ChallengeSucceeded(challengeID);
            if (wasWhitelisted) { _ListingRemoved(_listingHash); }
            else { _ApplicationRemoved(_listingHash); }
        }

        
        challenges[challengeID].resolved = true;

        
        challenges[challengeID].totalTokens =
            voting.getTotalNumberOfTokensForWinningOption(challengeID);
    }