random fixes for the loop handling