Fixed code not changing states