refactored mergeAll