database stats bug fix