Bugfix infinite loop