Added proper timeout handling