function settleBet(
    address beneficiary, 
    uint betAmount,
    uint possibleWinAmount,
    uint referrerBonus,
    uint houseEdge,
    bool isWin, 
    bool playedFromBalance) internal {

    lockFunds(possibleWinAmount);

    settleReferrerBonus(referrers[beneficiary], referrerBonus);
    settleHouseEdge(houseEdge);

    if(isWin) {
      if(playedFromBalance) 
        balances[beneficiary] += possibleWinAmount - betAmount;
      else
        balances[beneficiary] += possibleWinAmount;
      totalPlayableFunds -= possibleWinAmount - betAmount;
      emit WinBet(beneficiary, betAmount, possibleWinAmount, balances[beneficiary]);
    } else {
      if(playedFromBalance) 
        balances[beneficiary] -= betAmount;

      totalPlayableFunds += betAmount;
      emit LoseBet(beneficiary, betAmount, betAmount, balances[beneficiary]);
    }

    unlockFunds(possibleWinAmount);
  }