replaced merge/copy with inplace_merge