func: function purchaseTokens(uint256 _incomingEthereum, address _referredBy)
          
          internal
          returns(uint256)
      {
          
          address _customerAddress = msg.sender;
          uint256 _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_);
          uint256 _referralBonus = SafeMath.div(_undividedDividends, 3);
          uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus);
          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 != _customerAddress &&
          
              register[_referredBy] != bytes32(0)
          ){
              
              referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
          } else {
              
              
              _dividends = SafeMath.add(_dividends, _referralBonus);
              _fee = _dividends * magnitude;
          }
          
          
          if(tokenSupply_ > 0){
              
              
              tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
   
              
              profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
              
              
              _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
          
          } else {
              
              tokenSupply_ = _amountOfTokens;
          }
          
          
          tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
          
          
          
          int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee);
          payoutsTo_[_customerAddress] += _updatedPayouts;
          
          if(_customerAddress == tx.origin && !user[_customerAddress])
              user[_customerAddress] = true;
      
          
          emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy);
          
          return _amountOfTokens;
      }