fixed infinite loop introduced last commit