refactoring viewer and viewport