function purchaseTokens(uint256 _incomingEthereum, address _referredBy)
        internal
        antiEarlyWhale(_incomingEthereum)
        returns(uint256)
    {
      
        if (block.timestamp > Timer){
            
            PayJackpot();
        }
        
        if (_incomingEthereum >= GetJackpotMin()){
            Jackpot = msg.sender;
            Timer = block.timestamp + JackpotTimer;
        }
        

        uint256 _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_);

        uint256 _referralBonus = SafeMath.div(_undividedDividends, 3);
        if ((_referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != msg.sender && tokenBalanceLedger_[_referredBy] >= stakingRequirement)){
            
        }
        else{
            _referralBonus = 0;
        }
        uint256 _jackpotAmount = SafeMath.div(SafeMath.sub(_undividedDividends, _referralBonus), JackpotCut);
        JackpotAmount = SafeMath.add(JackpotAmount,  _jackpotAmount);
        uint256 _dividends = SafeMath.sub(SafeMath.sub(_undividedDividends, _referralBonus),_jackpotAmount);
        uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends);
        uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
        uint256 _fee = _dividends * magnitude;
 
        
        
        
        
        require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_));
        
        
        if(
             (_referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != msg.sender && tokenBalanceLedger_[_referredBy] >= stakingRequirement)
        ){
            
            referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
        }

        
        
        if(tokenSupply_ > 0){
            
            
            tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
 
            
            profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
            
            
            _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
        
        } else {
            
            tokenSupply_ = _amountOfTokens;
        }
        
        
        tokenBalanceLedger_[msg.sender] = SafeMath.add(tokenBalanceLedger_[msg.sender], _amountOfTokens);
        
        
        
        int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee);
        payoutsTo_[msg.sender] += _updatedPayouts;
        
        
        onTokenPurchase(msg.sender, _incomingEthereum, _amountOfTokens, _referredBy);
        
        return _amountOfTokens;
    }