Refactored dup code to method stats_filtered_by