proper db colsing