bugfix for endless loop