Added null check on optional parameter to avoid errors.
Added a null check to avoid an error when updating an entry without setting a limit or reading data first.