Updated merge.r script