Tighened up loop code
Stopped copying variables