fix minor bug that caused endless loop