bug in calculation of normal distance