Fixing floating point bug