refactor viewapp