function refundBet(uint commit,uint8 machineMode) external {
        
        Bet storage bet = bets[commit];
        uint amount = bet.amount;

        require (amount != 0, "Bet should be in an 'active' state");

        
        require (block.number > bet.placeBlockNumber.add(BetExpirationBlocks));

        
        bet.amount = 0;

        
        uint platformFee;
        uint jackpotFee;
        uint possibleWinAmount;
        uint upperLimit;
        uint maxWithdrawalPercentage;
        (upperLimit,maxWithdrawalPercentage) = getBonusPercentageByMachineMode(machineMode);
        (platformFee, jackpotFee, possibleWinAmount) = getPossibleWinAmount(maxWithdrawalPercentage,amount);

        
        lockedInBets = lockedInBets.sub(possibleWinAmount);

        
        sendFunds(bet.gambler, amount, amount);
    }