changed db code to handle disconnects