Added torch function, this currently places a torch every 5 iterations