Updated get_stats fuction