refator ui code