simplified and fixed for assymetric leaf values. 10 lines shorter