refactor view-related things from controller to view