corrected math path calculation