Add fetchEntitiesFromDB function