removed db close in the wrong place