fixed conversion problem when writing data