Use a safe_float function to store a float

And making the logic shorter as well (sort is good, right?)