Changed template provider to factory