changed merging algorithm: first functional successful test