Adding timeout functionality