There's a thumb rule to avoid confusion between which and that
use "which" if a group of words(surrounded by commas) adds information. use that if it limits the set of things you're talking about.
For example.. The books, which have red colours, are new.
Classes that are held on Wednesday are in this building.