write a view helper and refactor index page