refacotring the code and add tsocks config