close db only after done