fix loop and other fixes
clean