fix the join and merge bug