Added error handling
Added connection handling errors