postgres conversion to use maps