modified to add support owned and hidden flags