Fixing template mapping function.