added check to make sure object exists before running merge