Use `uid` instead of `key` and rename the static `uid` to `next_uid`.