That cannot be your actual code. It would give errors about redeclaring the nice variable.

Post your actual code.

You are probably redeclaring your variable inside your event handler, which means you are not changing the larger scoped variable with the same name.