more loop fixes