fix two minor bugs caused by typos
rewrite the merge function to actually work (hopefully)