bugfix loop check