Unexpected loop fixed