working version with the merging working