fix floating point bugs