Fixed output function so it gives sensible df output