made database access close safer