working on curvature calculation