Refactor merge intervals