refactoring and ui fix