loopcounter bugfix