fix some bugs and add timeout