fix bugs in timeout