refactor code for static pages