adding templating
made some changes