adding timeout to monitor states

This is not thoroughly tested, just opening the pull request in case someone wants to use it at his own risk