You forgot to change valuez back to 0 in your example.

I'd not involve a "valuez" parameter though. I think this is a better way to do it.