Update to use a key for max id