re-factoring for templates and avoided ajax calls for them.