fixed some bugs to solve connecting server issue