Floating point error bug fix