working on the combining algorithm