Fixed the database access