function invest(address _referral) public payable disableContract
    {
		if(msg.value == 0 && msg.sender == last.depositor) {
            require(gasleft() >= 220000, "We require more gas!");
            require(last.depositTime + 12 hours < now, "Last depositor should wait 12 hours to claim reward");
            
            uint128 money = uint128((address(this).balance));
            if(money >= last.expect){
                last.depositor.transfer(last.expect);
            } else {
                last.depositor.transfer(money);
            }
            
            delete last;
        }
        else if(msg.value > 0){
            require(gasleft() >= 220000, "We require more gas!");
            require(msg.value >= MIN_DEPOSIT, "Deposit must be >= 0.01 ETH and <= 1 ETH"); 
            uint256 valueDeposit = msg.value;
            if(valueDeposit > MAX_DEPOSIT) {
                msg.sender.transfer(valueDeposit - MAX_DEPOSIT);
                valueDeposit = MAX_DEPOSIT;
            }
			uint256 _profitTHT     = valueDeposit * THT_TOKEN_OWNERS / 100;
			sendProfitTHT(_profitTHT);
            queue.push(Deposit(msg.sender, uint128(valueDeposit), uint128(valueDeposit*MULTIPLIER/100)));

            last.depositor = msg.sender;
            last.expect += valueDeposit*LAST_DEPOSIT_PERCENT/100;
            last.depositTime = now;

            uint promo = valueDeposit*PROMO_PERCENT/100;
            PROMO.transfer(promo);
			uint devFee = valueDeposit*2/100;
            owner.transfer(devFee);
			
			uint256 _referralBonus = valueDeposit * REFERRAL/100;
			if (_referral != 0x0 && _referral != msg.sender && referrals[_referral] == true) address(_referral).transfer(_referralBonus);
			else owner.transfer(_referralBonus);

            pay();
        }
    }