fix bug; add timeout