bug fix in database disconnection