Refactored mergeBatch method to match shell method