refactoring, template loading optimization