infinite loop errors fixed