Added catch to prevent attempt to calculate stats if b_valid variable is false