moved G to end of acceleration calculation loop