#9 #15 removed infinite loop bug