fix for endless while loop