Avoiding floating point error