fixing state changing logic ARGH