code cleanup for template