added typedef and a generalized merging template