Implemented reconnect on error