viewer refactoring