measure functions are attached to recursive functions.
removed unused vars.