This is a very minor stylistic suggestion, but once you've copied `result.metadata` into `entry.metadata`, it might be nice to always use `entry.metadata` later on in the function, just to clarify that entry is really fully constructed at that point and you don't really need the original result argument anymore.