  Let A be an alphabet and W be a set of words in the free monoid A*. Let S(W)
denote the Rees quotient over the ideal of A* consisting of all words that are
not subwords of words in W. We call a set of words W finitely based if the
monoid S(W) is finitely based.
  We find a simple algorithm that recognizes finitely based words among words
with at most two non-linear variables. We also describe syntactically all
hereditary finitely based monoids of the form S(W).
