Added exception handler
Eliminated unneccessary connecting
Moved logging statement