function buy(Player storage _player, InternalBuyEvent memory _buyEvent, uint256 _amount) private {
        require(now < finishTime && _amount >= BUY_AMOUNT_MIN && _amount <= BUY_AMOUNT_MAX);
        
        uint256 _day = (now / 86400) * 86400;
        uint256 _backEth = 0;
        uint256 _eth = _amount;
        if (totalPot < 200000000000000000000) {
            
            if (_eth >= 5000000000000000000) {
                
                _backEth = _eth.sub(5000000000000000000);
                _eth = 5000000000000000000;
            }
        }
        txCount = txCount + 1; 
        _buyEvent.flag1 += txCount * 10; 
        _player.ethTotal = _player.ethTotal.add(_eth);
        totalPot = totalPot.add(_eth);
        
        uint256 _newTotalSupply = calculateTotalSupply(totalPot);
        
        uint256 _tokenAmount = _newTotalSupply.sub(totalSupply);
        _player.tokenBalance = _player.tokenBalance.add(_tokenAmount);
        
        
        if (_player.tokenDay == _day) {
            _player.tokenDayBalance = _player.tokenDayBalance.add(_tokenAmount);
        } else {
            _player.tokenDay = _day;
            _player.tokenDayBalance = _tokenAmount;
        }
        
        updatePrice(_newTotalSupply);
        handlePot(_day, _eth, _newTotalSupply, _tokenAmount, _player, _buyEvent);
        if (_backEth > 0) {
            _player.ethBalance = _player.ethBalance.add(_backEth);
        }
        sendFeeIfAvailable();
        emitEndTxEvents(_eth, _tokenAmount, _buyEvent);
    }