Thread for checking substitutions