Configure UI and simplify code logic.