changed to httpclient, fixed all code and removed unused function