found and fixed potential infinite loop