fix never ending loop