This seems strange. So every time you are finished with a function, the count is reset to zero. What if it's a function in a function? The count is reset to zero and you have no record of what happened before the inner function. Seems like a stack is on order here.