fixed infinite loop

should fix #454