function placeBetWithInviter(uint betMask, address inviter) external payable {
     
    uint amount = msg.value;
    require (amount >= MIN_BET && amount <= MAX_AMOUNT, "Amount should be within range.");
    require (address(this) != inviter && inviter != address(0), "cannot invite myself");
    
    uint mask;
    
    require (betMask > 2 && betMask <= 96, "High modulo range, betMask larger than modulo.");
    uint possibleWinAmount;
    uint jackpotFee;
    
    (possibleWinAmount, jackpotFee) = getDiceWinAmount(amount, betMask);
    
    
    require (possibleWinAmount <= amount + maxProfit, "maxProfit limit violation. ");
    
    
    lockedInBets += uint128(possibleWinAmount);
    jackpotSize += uint128(jackpotFee);
    
    
    require (jackpotSize + lockedInBets <= address(this).balance, "Cannot afford to lose this bet.");

    bytes32 rngId = oraclize_query("WolframAlpha","random number between 1 and 1000", oraclizeGasLimit);
    
    
    emit Commit(rngId);

    
    Bet storage bet = bets[rngId];
    bet.amount = amount;
    
    bet.rollUnder = uint8(betMask);
    bet.placeBlockNumber = uint40(block.number);
    bet.mask = uint40(mask);
    bet.gambler = msg.sender;
    bet.inviter = inviter;
    
    uint accuAmount = accuBetAmount[msg.sender];
    accuAmount = accuAmount + amount;
    accuBetAmount[msg.sender] = accuAmount;
    
  }