this may leak memory: `result, DEN(result), f, g`!