fix leaf ordering