adapted this so that the mapping logic lives on the server/query side