Added timeout handling