add back the invariant

and make sure the complete path has been matched