Adding an accumulator and handling different states
Handling merge