Adding timeout detection