changed template functionality and added custom error pages