Refactor convert_float method