contract Owned {
    address[] public pools;
    address public owner;

    function Owned() {
        owner = msg.sender;
        pools.push(msg.sender);
    }

    modifier onlyPool {
        require(isPool(msg.sender));
        _;
    }

    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }
    
    /// add new pool address to pools
    function addPool(address newPool) onlyOwner {
        assert (newPool != 0);
        if (isPool(newPool)) throw;
        pools.push(newPool);
    }
    
    /// remove a address from pools
    function removePool(address pool) onlyOwner{
        assert (pool != 0);
        if (!isPool(pool)) throw;
        
        for (uint i=0; i<pools.length - 1; i++) {
            if (pools[i] == pool) {
                pools[i] = pools[pools.length - 1];
                break;
            }
        }
        pools.length -= 1;
    }

    function isPool(address pool) internal returns (bool ok){
        for (uint i=0; i<pools.length; i++) {
            if (pools[i] == pool)
                return true;
        }
        return false;
    }
    
    function transferOwnership(address newOwner) onlyOwner public {
        removePool(owner);
        addPool(newOwner);
        owner = newOwner;
    }
}
/**
 * Owned contract
 */
function addPool(address newPool) onlyOwner {
    assert (newPool != 0);
    if (isPool(newPool)) throw;
    pools.push(newPool);
}

/// add new pool address to pools