refactoring and tidying up plus new ui features