implementing template engine