added support for timeout, fixes #10