adding timeout option and fixing output of a failed state