Fixing template edit code