bug fix for leaf nodes