fixed infinite loops