improved external template loading process