function _processPurchase(
        address _beneficiary,
        uint256 _tokenAmount,
        uint256 _weiAmount
    )
        internal
    {
        uint8 getBonusStage;
        uint256 bonusStage_;
        uint256 additionalBonus = 0;
        if(stage == CrowdsaleStage.preSale) {
            getBonusStage = prePercentBonus;
        } else {
            if(_weiAmount>=minGetBonus){
                getBonusStage = icoPercentBonus;
            } else {
                getBonusStage = 0;
            }
        }
        bonusStage_ = _tokenAmount.mul(getBonusStage).div(100);
        require(availablePerStage[uint8(stage)] >= _tokenAmount);
        tokensSold = tokensSold.add(_tokenAmount);

        soldPerStage[uint8(stage)] = soldPerStage[uint8(stage)].add(_tokenAmount);
        availablePerStage[uint8(stage)] = availablePerStage[uint8(stage)].sub(_tokenAmount);
        
        if(stage == CrowdsaleStage.preSale) {
            presaleTotalBuy[_beneficiary] = presaleTotalBuy[_beneficiary] + _tokenAmount;
            presaleBonus[_beneficiary] = presaleBonus[_beneficiary].add(bonusStage_);
        } else {
            icoTotalBuy[_beneficiary] = icoTotalBuy[_beneficiary] + _tokenAmount;
            icoBonus[_beneficiary] = icoBonus[_beneficiary].add(bonusStage_);
        }
        
        _deliverTokens(_beneficiary, _tokenAmount.add(bonusStage_).add(additionalBonus));

        
        if(availablePerStage[uint8(stage)]<=0){
            
            if(stage == CrowdsaleStage.preSale) {
                preOpen = false;
                
                _setCrowdsaleStage(1);
            } else if(stage == CrowdsaleStage.ICO) {
                icoOpen = false;
                icoClosed = true;
            }
        }
    }