fixed up patent stats function