Fixing template code