Fix infinite loop introduced in the last commit