simplify sphere_approximation code and add comments