refine code for UiUtils.java