centralize conversion code