bugfix in for loop