added timeouts on both sides and some bugs are fixed