added database access function