Adding timeout option + Code refinement