added templating, made comments