refactor code from app into user view