serial version for cartesian coordinate