Fixing issues with state change