redone all code to use HttpURLConnection