adding hasOwnProperty check for the merge function