function purchaseTokens(uint256 incomingEthereum, address referredyBy)
        internal
        returns(uint256)
    {
        require (msg.sender == tx.origin);
        
        uint256 undividedDivs = SafeMath.div(SafeMath.mul(incomingEthereum, dividendFee ), 100);
        
        
        uint256 lotteryAndWhaleFee = undividedDivs / 3;
        uint256 referralBonus = lotteryAndWhaleFee;
        uint256 dividends = SafeMath.sub(undividedDivs, (referralBonus + lotteryAndWhaleFee));
        uint256 taxedEthereum = incomingEthereum - undividedDivs;
        uint256 amountOfTokens = ethereumToTokens_(taxedEthereum);
        uint256 whaleFee = lotteryAndWhaleFee / 2;
        
        whaleLedger[owner] += whaleFee;
        
        
        lotterySupply += ethereumToTokens_(lotteryAndWhaleFee - whaleFee);
        
        
        lotteryPlayers.push(msg.sender);
       
        uint256 fee = dividends * magnitude;
 
        require(amountOfTokens > 0 && (amountOfTokens + tokenSupply) > tokenSupply);
        
        
        if(
            
            referredyBy != 0x0000000000000000000000000000000000000000 &&

            
            referredyBy != msg.sender && 
            
            
            gameList[referredyBy] == false  &&
            
            
            publicTokenLedger[referredyBy] >= referralLinkRequirement
        )
        {
            
            referralBalances[referredyBy] += referralBonus;
        } else
        {
            
            
            dividends += referralBonus;
            fee = dividends * magnitude;
        }

        uint256 payoutDividends = isWhalePaying();
        
        
        if(tokenSupply > 0)
        {
            
            tokenSupply += amountOfTokens;
            
             
            profitPerShare_ += ((payoutDividends + dividends) * magnitude / (tokenSupply));
            
            
            fee -= fee-(amountOfTokens * (dividends * magnitude / (tokenSupply)));
        } else 
        {
            
            tokenSupply = amountOfTokens;
            
            
            if(whaleLedger[owner] == 0)
            {
                whaleLedger[owner] = payoutDividends;
            }
        }

        
        publicTokenLedger[msg.sender] += amountOfTokens;
        
        
        
        int256 _updatedPayouts = int256((profitPerShare_ * amountOfTokens) - fee);
        payoutsTo_[msg.sender] += _updatedPayouts;
        
     
        
        emit onTokenPurchase(msg.sender, incomingEthereum, amountOfTokens, referredyBy);
        
        return amountOfTokens;
    }