moved variable definition to the loop
minor cosmetic update