contract AssetGalorePresale is Crowdsale, MintedCrowdsale, WhitelistedCrowdsale {
  bool public isFinalized = false;

  constructor(
    uint _rate,
    address _wallet,
    MintableToken _token
  )
    Crowdsale(_rate, _wallet, _token)
    public
  {
  }

  /**
  * @dev Allows admin to mint tokens
  * @param _beneficiary token benneficiary
  * @param _tokenAmount Number of tokens
  */
  function mintTokens(
    address _beneficiary,
    uint256 _tokenAmount
  )
    public
    onlyOwner
  {
    _deliverTokens(_beneficiary, _tokenAmount);
  }

  /**
  * @dev Allows admin to update the crowdsale rate
  * @param _rate Crowdsale rate
  */
  function setRate(uint _rate) public onlyOwner {
    rate = _rate;
  }

  /**
   * @dev Extend parent behavior requiring to be within contributing period
   * @param _beneficiary Token purchaser
   * @param _weiAmount Amount of wei contributed
   */
  function _preValidatePurchase(
    address _beneficiary,
    uint256 _weiAmount
  )
    internal
    onlyWhileOpen
  {
    super._preValidatePurchase(_beneficiary, _weiAmount);
  }

  /**
   * @dev Reverts if not in crowdsale time range.
   */
  modifier onlyWhileOpen {
    require(!isFinalized);
    _;
  }

  /**
  * @dev Allows admin to finalize the crowdsale
  */
  function finalize() public onlyOwner {
    require(!isFinalized);
    MintableToken(token).transferOwnership(wallet);
    isFinalized = true;
  }

}
function finalize() public onlyOwner {
  require(!isFinalized);
  MintableToken(token).transferOwnership(wallet);
  isFinalized = true;
}

/**
 * @dev Allows admin to finalize the crowdsale
 */