Refactor ui