added block to check if key already exists.