Fixed bug in hierarchy lookup