added DB connection closing code