modify db connect and add db close