Fix JavaScript and counter