restructuring for php templating