@Ryebot33
Have you read through this? It sounds like you are trying to do the same thing. Not saying that stateDuration will not work, but I used elapsed in the aforementioned thread
stateDuration
elapsed