put counter inside loop