I modified the original script to not include variables for each coordinate. May be slower than the original.