small refactoring and reorganizing code in views and ui