fixed templates, added functionality