Fix bug with states