function bet(bool startNewGameIfIdle) external payable {
		require(msg.value >= price);
		
        _processGameEnd();
		
        if (!gameStarted) {
            require(!paused);

            require(startNewGameIfIdle);
            
            price = nextPrice;
            timeout = nextTimeout;
            minimumTimeout = nextMinimumTimeout;
            numberOfWagersToMinimumTimeout = nextNumberOfWagersToMinimumTimeout;
            
            gameStarted = true;
            
            gameStarter = msg.sender;
            
            Start(msg.sender, now, price, timeout, minimumTimeout, numberOfWagersToMinimumTimeout);
        }
        
        
        uint256 fee = price.mul(feePercentage).div(100000);
        uint256 dividend = price.mul(gameStarterDividendPercentage).div(100000);
		
        uint256 wagerPool5Part;
		uint256 wagerPool13Part;
        
		
        wagerPool5Part = price.mul(2).div(10);
		wagerPool13Part = price.mul(3).div(26);
            
        
        wagerPool5 = wagerPool5.add(wagerPool5Part);
		wagerPool13 = wagerPool13.add(wagerPool13Part);
		
		prizePool = prizePool.add(price);
		prizePool = prizePool.sub(fee);
		prizePool = prizePool.sub(dividend);
		prizePool = prizePool.sub(wagerPool5Part);
		prizePool = prizePool.sub(wagerPool13Part);
		
		if (wagerIndex % 5 == 4) {
            
			
            uint256 wagerPrize5 = price.mul(2);
            
            
            uint256 difference5 = wagerPrize5.sub(wagerPool5);
			prizePool = prizePool.sub(difference5);
        
            msg.sender.transfer(wagerPrize5);
            
            wagerPool5 = 0;
        }
		
		if (wagerIndex % 13 == 12) {
			
			
			uint256 wagerPrize13 = price.mul(3);
			
			uint256 difference13 = wagerPrize13.sub(wagerPool13);
			prizePool = prizePool.sub(difference13);
			
			msg.sender.transfer(wagerPrize13);
			
			wagerPool13 = 0;
		}

		player5 = player4;
		player4 = player3;
		player3 = player2;
		player2 = lastPlayer;
		
		player5Timestamp = player4Timestamp;
		player4Timestamp = player3Timestamp;
		player3Timestamp = player2Timestamp;
		
		if (lastWagerTimeoutTimestamp > currentTimeout) {
			player2Timestamp = lastWagerTimeoutTimestamp.sub(currentTimeout);
		}
		
		currentTimeout = calculateTimeout();
		
        lastPlayer = msg.sender;
        lastWagerTimeoutTimestamp = now + currentTimeout;
        
		wagerIndex = wagerIndex.add(1);
		
        Bet(msg.sender, now, lastWagerTimeoutTimestamp, wagerIndex, prizePool);
        
        _sendFunds(gameStarter, dividend);
		
        
        uint256 excess = msg.value - price;
        
        if (excess > 0) {
            msg.sender.transfer(excess);
        }
		
		currentBalance = this.balance;
    }