fixed nullpinter bug when checking the substitution key's validity