fixed finding the key of the last registered entity.
just add. exists is checked inside add method.