Change capstats function to return results instead of printing