contract PostDeliveryCrowdsale is TimedCrowdsale {
    using SafeMath for uint256;

    /**
    * @dev contains virtual balances.
    * All balance records are written
    * here until softcap is reached
    */
    mapping(address => uint256) private _balances;

    /**
    * @dev list of backers with virtual balances
    */
    address[] private _backers;

    /**
     * @dev Withdraw tokens only after crowdsale ends.
     * @param beneficiary Whose tokens will be withdrawn.
     */
    function withdrawTokens(address beneficiary) public {
        require(goalReached());
        uint256 amount = _balances[beneficiary];
        require(amount > 0);
        _balances[beneficiary] = 0;
        _deliverTokens(beneficiary, amount);
    }

    /**
     * @return the balance of an account.
     */
    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }

    function backers() public view returns (address[] memory) {
        return _backers;
    }

    /**
     * @dev Overrides parent by storing balances instead of issuing tokens right away.
     * @param beneficiary Token purchaser
     * @param tokenAmount Amount of tokens purchased
     */
    function _processPurchase(address beneficiary, uint256 tokenAmount) internal {
        if (!goalReached()) {
            _balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
            _backers.push(beneficiary);
            _addSold(tokenAmount);
            return;
        }
        super._processPurchase(beneficiary, tokenAmount);
    }
}
/**
 * @title PostDeliveryCrowdsale
 * @dev Crowdsale that locks tokens from withdrawal until it ends.
 */
function _processPurchase(address beneficiary, uint256 tokenAmount) internal {
    if (!goalReached()) {
        _balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
        _backers.push(beneficiary);
        _addSold(tokenAmount);
        return;
    }
    super._processPurchase(beneficiary, tokenAmount);
}

/**
 * @dev Overrides parent by storing balances instead of issuing tokens right away.
 * @param beneficiary Token purchaser
 * @param tokenAmount Amount of tokens purchased
 */