refactor functions ui