function claimRefund() external {
    uint256 depositedValue = 0;

    if (isCrowdsaleFinalized && !crowdsaleGoalReached()) {
      require(crowdsaleDeposited[msg.sender] > 0);
      depositedValue = crowdsaleDeposited[msg.sender];
      crowdsaleDeposited[msg.sender] = 0;
    } else if (isPresaleFinalized && !presaleGoalReached()) {
      require(presaleDeposited[msg.sender] > 0);
      depositedValue = presaleDeposited[msg.sender];
      presaleDeposited[msg.sender] = 0;
    }

    require(depositedValue > 0);
    msg.sender.transfer(depositedValue);
    emit Refunded(msg.sender, depositedValue);
  }