refactor ui state