Doesn't work correctly? What does it do or not do that is wrong. You kind of left out the symptoms didn't you. Sort of the most important piece don't you think?

You're not counting the number of presses. You just keep incrementing a variable as long as the button is held.

Go look at the State Change example. I think it will give you the idea you need.