solves overlapping steps and same level merges