fix for some duplicate code in template