Updating templates and adding more db interaction