Bug fix with templates