implement merge method