State Not Removing Correctly

Is there a difference to states when applying them directly to enemies through troop battle events or through a plugin with the 


$gameTroop.members()[_targetIndex].addState(_stateId);


 type format? I'm having a problem with the state not removing itself. If I apply the same state to an enemy through the battle events page, the auto-removal timing that I have set for 3-5 turns works as it should. However if I apply the same exact state (and it IS only applying it once. I checked to make sure my code wasn't reiterating and just constantly apply the state) by using 


$gameTroop.members()[_targetIndex].addState(_stateId);


the state never actually goes away. Any ideas on what I could be missing?


*Edit - Well, that's weird. Apparently I was passing _stateId as a string and that was still allowing the state to be applied. Once I passed it as


addState(Number(_stateId));


instead, the auto-removal timing worked as it should. This should really have some kind of fail-safe as it's very easy to miss the fact that the ID is passed as a string instead of a number because the state still gets applied...

Original thread: https://forums.rpgmakerweb.com/threads/state-not-removing-correctly.60572/