FIXING ENLESS LOOP