contract Presale is CommonTokensale {

    // In case min (soft) cap is not reached, token buyers will be able to
    // refund their contributions during 3 months after presale is finished.

    // Total amount of wei refunded if min (soft) cap is not reached.
    uint public totalWeiRefunded;

    event RefundEthEvent(address indexed _buyer, uint256 _amountWei);

    constructor(
        address _token,
        address _beneficiary,
        uint _startTime,
        uint _endTime
    ) CommonTokensale(
        _token,
        _beneficiary,
        _startTime,
        _endTime
    ) public {
      refundDeadlineTime = _endTime + 3 * 30 days;
    }

    /**
     * During presale it will be possible to withdraw only in two cases:
     * min cap reached OR refund period expired.
     */
    function canWithdraw() public view returns (bool) {
        return isSoftCapComplete;
    }

    /**
     * It will be possible to refund only if min (soft) cap is not reached and
     * refund requested during 3 months after presale finished.
     */
    function canRefund() public view returns (bool) {
        return !isSoftCapComplete && endTime < now && now <= refundDeadlineTime;
    }

    function refund() public {
        require(canRefund());

        address buyer = msg.sender;
        uint amount = buyerToSentWei[buyer];
        require(amount > 0);

        // Redistribute left balance between three beneficiaries.
        uint newBal = balance.sub(amount);
        balance = newBal;

        emit RefundEthEvent(buyer, amount);
        buyerToSentWei[buyer] = 0;
        totalWeiRefunded = totalWeiRefunded.add(amount);
        buyer.transfer(amount);
    }
}
function canRefund() public view returns (bool) {
        return !isSoftCapComplete && endTime < now && now <= refundDeadlineTime;
    }
/**
 * It will be possible to refund only if min (soft) cap is not reached and
 * refund requested during 3 months after presale finished.
 */