refactored the ui code (in relation to #54)