use approximate length instead of r_nx*dx; minor changes
some changes