refactored some ui code