reformat and working on loop