bug fix in df calculation