The purpose of this work is to generalize part of the theory behind Faugere's "F5" algorithm. This is one of the fastest known algorithms to compute a Groebner basis of a polynomial ideal I generated by polynomials f_{1},...,f_{m}. A major reason for this is what Faugere called the algorithm's "new" criterion, and we call "the F5 criterion"; it provides a sufficient condition for a set of polynomials G to be a Groebner basis. However, the F5 algorithm is difficult to grasp, and there are unresolved questions regarding its termination. This paper introduces some new concepts that place the criterion in a more general setting: S-Groebner bases and primitive S-irreducible polynomials. We use these to propose a new, simple algorithm based on a revised F5 criterion. The new concepts also enable us to remove various restrictions, such as proving termination without the requirement that f_{1},...,f_{m} be a regular sequence.