Fixed bug with counter