Merging the states in a better way