implementing function with a tree structured evaluation system.