Moved hierarchy key outside loop

  * hierarachy keys were incorrectly expressed