add getOrTimeout
improve code
improve code