refactor view handler