fixed database access bug