fixed bug in hierarchy magic