Adjusted filtering in summary calculations for accuracy; removed debugging code (print(v)) in last step