refactor main viewer class