function _preValidatePurchase(
        address _beneficiary,
        uint256 _weiAmount
    ) internal whenNotPaused {
        
        require(
            tx.gasprice <= maxGasPrice,
            "Gas price is too expensive. Don't be competitive."
        );

        super._preValidatePurchase(_beneficiary, _weiAmount);

        uint8 grade = whitelist[_beneficiary];
        require(grade > 0, "Not whitelisted.");
        uint openingTime = whitelistGrades[grade];
        require(
            
            block.timestamp >= openingTime,
            "Currently unavailable to purchase tokens."
        );

        uint256 contribution = contributions[_beneficiary];
        uint256 contributionAfterPurchase = contribution.add(_weiAmount);

        
        
        
        
        require(
            contributionAfterPurchase >= individualMinPurchaseWei,
            "Sent ethers is not enough."
        );

        
        uint256 individualMaxWei = 0;
        for (uint i = 0; i < individualMaxCaps.length; i++) {
            uint256 capTimestamp = individualMaxCaps[i].timestamp;
            
            if (capTimestamp <= block.timestamp) {
                individualMaxWei = individualMaxCaps[i].maxWei;
            } else {
                
                if (i > 1) {
                    uint offset = i - 1;
                    uint trimmedLength = individualMaxCaps.length - offset;
                    for (uint256 j = 0; j < trimmedLength; j++) {
                        individualMaxCaps[j] = individualMaxCaps[offset + j];
                    }
                    individualMaxCaps.length = trimmedLength;
                }
                break;
            }
        }
        require(
            contributionAfterPurchase <= individualMaxWei,
            individualMaxWei > 0
                ? "Total ethers you've purchased is too much."
                : "Purchase is currently disallowed."
        );
    }