Factor out data conversion