loop fixes