Use correct counter variable

It must be counter instead of value.