added change state logic