added checks for the class of the new object