contract SchedulableToken is StandardToken, BurnableToken {
  using SafeMath for uint256;

  event Released(uint256 amount);

  address public beneficiary;
  uint256 public maxSupply;
  uint256 public start;
  uint256 public duration;

  /**
   * @dev Constructor of the SchedulableToken contract that releases the tokens gradually and
   * programmatically. The balance will be assigned to _beneficiary in the maximum amount of
   * _maxSupply, divided proportionally during the _duration period.
   * @param _beneficiary address of the beneficiary to whom schedulable tokens will be added
   * @param _maxSupply schedulable token max supply
   * @param _duration duration in seconds of the period in which the tokens will released
   */
  function SchedulableToken(address _beneficiary, uint256 _maxSupply, uint256 _duration) public {
    require(_beneficiary != address(0));
    require(_maxSupply > 0);
    require(_duration > 0);

    beneficiary = _beneficiary;
    maxSupply = _maxSupply;
    duration = _duration;
    start = now;
  }

  /**
   * @notice Transfers schedulable tokens to beneficiary.
   */
  function release() public {
    uint256 amount = calculateAmountToRelease();
    require(amount > 0);

    balances[beneficiary] = balances[beneficiary].add(amount);
    totalSupply = totalSupply.add(amount);

    Released(amount);
  }

  /**
   * @dev Calculates the amount of tokens by right, until that moment.
   */
  function calculateAmountToRelease() public view returns (uint256) {
    if (now < start.add(duration)) {
      return maxSupply.mul(now.sub(start)).div(duration).sub(totalSupply);
    } else {
      return schedulableAmount();
    }
  }

  /**
   * @dev Returns the total amount that still to be released by the end of the duration.
   */
  function schedulableAmount() public view returns (uint256) {
    return maxSupply.sub(totalSupply);
  }

  /**
  * @dev Overridden the BurnableToken burn() function to also correct maxSupply.
  * @param _value The amount of token to be burned.
  */
  function burn(uint256 _value) public {
    super.burn(_value);
    maxSupply = maxSupply.sub(_value);
  }
}
/**
 * @title SchedulableToken
 * @dev The SchedulableToken provide a method to create tokens progressively, in a gradual
 * and programed way, until a specified date and amount. To effectively create tokens, it
 * is necessary for someone to periodically run the release() function in the contract.
 * For example: You want to create a total of 1000 tokens (maxSupply) spread over 2 years (duration).
 * In this way, when calling the release() function, the number of tokens that are entitled at
 * that moment will be added to the beneficiary's wallet. In this scenario, by running the
 * release() function every day at the same time over 2 years, the beneficiary will receive
 * 1.37 tokens (1000 / 364.25 * 2) everyday.
 * @author Anselmo Zago (anselmo@letsfair.org), based in TokenVesting by Zeppelin Solidity library.
 */
function schedulableAmount() public view returns (uint256) {
    return maxSupply.sub(totalSupply);
  }
/**
 * @dev Returns the total amount that still to be released by the end of the duration.
 */