contract Whitelist is Pausable {
  mapping(address => bool) public whitelist;
  uint public numberOfWhitelists;
  event WhitelistedAddressAdded(address addr);
  event WhitelistedAddressRemoved(address addr);

  /**
   * @dev Throws if called by any account that's not whitelisted.
   */
  modifier onlyWhitelisted() {
    require(whitelist[msg.sender]);
    _;
  }

  constructor() public {
    whitelist[msg.sender] = true;
    numberOfWhitelists = 1;
    emit WhitelistedAddressAdded(msg.sender);
  }
  /**
   * @dev add an address to the whitelist
   * @param addr address
   * @return true if the address was added to the whitelist, false if the address was already in the whitelist
   */
  function addAddressToWhitelist(address addr) onlyWhitelisted whenNotPaused public returns(bool success) {
    if (!whitelist[addr]) {
      whitelist[addr] = true;
      numberOfWhitelists++;
      emit WhitelistedAddressAdded(addr);
      success = true;
    }
  }

  /**
   * @dev remove an address from the whitelist
   * @param addr address
   * @return true if the address was removed from the whitelist,
   * false if the address wasn't in the whitelist in the first place
   */
  function removeAddressFromWhitelist(address addr) onlyWhitelisted whenNotPaused public returns(bool success) {
    require(numberOfWhitelists > 1);
    if (whitelist[addr]) {
      whitelist[addr] = false;
      numberOfWhitelists--;
      emit WhitelistedAddressRemoved(addr);
      success = true;
    }
  }

}
function addAddressToWhitelist(address addr) onlyWhitelisted whenNotPaused public returns(bool success) {
  if (!whitelist[addr]) {
    whitelist[addr] = true;
    numberOfWhitelists++;
    emit WhitelistedAddressAdded(addr);
    success = true;
  }
}

/**
 * @dev add an address to the whitelist
 * @param addr address
 * @return true if the address was added to the whitelist, false if the address was already in the whitelist
 */