add template and lazy support