added more sophisticated template engine