fix bug in merge method