added templates, removed duplicated javascript