Hierarchy has queries now, incorporated into original code