tweaked function to map ids between databases