Using the non-leaf function technique to implement leaf functions