Added Multithreading
Added connection failure check