refactor of views logic