If you want to call the same code again, you just need to create a private function with the shared code, and calling it in both forward.
And by the way:
Trim() should be called before the check.
TrieGetCell() -> TrieKeyExists ; since you don't need associated value.
Call TrieDestroy() on plugin_end() forward.
set_fail_state() can format string, but not sure in what AMXX version it's available.