function invest(address _referer) public {

            
              
            uint _value = token.allowance(msg.sender, address(this));

            
              
            token.transferFrom(msg.sender, address(this), _value);
            
              
            refBonus[owner] = refBonus[owner].add(_value.div(10));

            
              
            if (deposit[msg.sender] > 0) {
                
                
                  
                  
                uint amountToWithdraw = (block.timestamp.sub(lastTimeWithdraw[msg.sender])).div(1 days).mul(deposit[msg.sender].mul(311).div(10000));
                
                  
                if (amountToWithdraw != 0) {
                    
                      
                    withdrawn[msg.sender] = withdrawn[msg.sender].add(amountToWithdraw);
                    
                      
                    token.transfer(msg.sender, amountToWithdraw);

                    
                    uint _bonus = refBonus[msg.sender];
                    if (_bonus != 0) {
                        refBonus[msg.sender] = 0;
                        token.transfer(msg.sender, _bonus);
                        withdrawn[msg.sender] = withdrawn[msg.sender].add(_bonus);
                    }

                }
                
                  
                lastTimeWithdraw[msg.sender] = block.timestamp;
                
                  
                deposit[msg.sender] = deposit[msg.sender].add(_value);
                
                  

                
                if (refIsSet[msg.sender]) {
                      refSystem(_value, referers[msg.sender]);
                  } else if (_referer != 0x0 && _referer != msg.sender) {
                      setRef(_value, _referer);
                  }
                return;
            }
            
            
              
              
            lastTimeWithdraw[msg.sender] = block.timestamp;
            
            
            deposit[msg.sender] = (_value);
            deposits += 1;

            
            if (refIsSet[msg.sender]) {
                refSystem(_value, referers[msg.sender]);
            } else if (_referer != 0x0 && _referer != msg.sender) {
                setRef(_value, _referer);
            }
        }