working on templating
refactored page loading