bugfixes for for-loops