Added a helper for merging stacks