added magic function that has access to output metadata