refactor to timeout