update merge function to check prototype of constructor of the object instead of type, to check that it's an instance of Object and not just a subclass of object