fix connection timeout and separate inner class to be class