context analysis: merge duplicate states