Refactor code with better UI