Fixed bug "infinite loop"