removed another function being defined within a loop
moved another function definition outside of a loop