diff --git a/src/main/java/com/iemr/flw/controller/IncentiveController.java b/src/main/java/com/iemr/flw/controller/IncentiveController.java
index ba60dffb..52d36ad2 100644
--- a/src/main/java/com/iemr/flw/controller/IncentiveController.java
+++ b/src/main/java/com/iemr/flw/controller/IncentiveController.java
@@ -29,6 +29,9 @@ public class IncentiveController {
     @Autowired
     IncentiveService incentiveService;
 
+    @Autowired
+    private JwtUtil jwtUtil;
+
     @Operation(summary = "save incentive master")
     @RequestMapping(value = {"/masterData/saveAll"}, method = {RequestMethod.POST})
     public String saveIncentiveMasterData(@RequestBody List<IncentiveActivityDTO> activityDTOS, @RequestHeader(value = "Authorization") String authorization, HttpServletRequest request) {
@@ -81,11 +84,17 @@ public String saveIncentiveMasterData(@RequestBody IncentiveRequestDTO incentive
     @Operation(summary = "get high risk assessment data of all beneficiaries registered with given user id")
     @RequestMapping(value = {"/fetchUserData"}, method = {RequestMethod.POST})
     public String getAllIncentivesByUserId(@RequestBody GetBenRequestHandler requestDTO,
-                                           @RequestHeader(value = "Authorization") String Authorization) {
+                                           @RequestHeader(value = "jwtToken") String token) {
         OutputResponse response = new OutputResponse();
         try {
 
             if (requestDTO != null) {
+
+                if(token!=null){
+                    requestDTO.setUserId(jwtUtil.extractUserId(token));
+                    requestDTO.setAshaId(jwtUtil.extractUserId(token));
+                    requestDTO.setUserName(jwtUtil.extractUsername(token));
+                }
                 logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " "
                         + requestDTO);
                 String s = incentiveService.getAllIncentivesByUserId(requestDTO);
diff --git a/src/main/java/com/iemr/flw/repo/identity/BeneficiaryRepo.java b/src/main/java/com/iemr/flw/repo/identity/BeneficiaryRepo.java
index 3af9cd6b..3e82c391 100644
--- a/src/main/java/com/iemr/flw/repo/identity/BeneficiaryRepo.java
+++ b/src/main/java/com/iemr/flw/repo/identity/BeneficiaryRepo.java
@@ -12,6 +12,7 @@
 import java.math.BigInteger;
 import java.sql.Timestamp;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Optional;
 import java.util.stream.Stream;
 
@@ -89,6 +90,18 @@ Page<RMNCHMBeneficiaryaddress> getBenDataWithinDates(
     RMNCHMBeneficiarydetail findByBeneficiaryDetailsId(@Param("beneficiaryDetailsId") BigInteger beneficiaryDetailsId);
 
 
-
-
+    // BeneficiaryRepo — replaces 3 separate queries per beneficiary
+    @Query(value = """
+    SELECT 
+        ibd.BeneficiaryId    AS benId,
+        bd.firstName         AS firstName,
+        bd.lastName          AS lastName
+    FROM db_identity.i_beneficiarydetails_rmnch ibd
+    JOIN db_identity.i_beneficiarymapping bm 
+        ON bm.BenRegId = ibd.BeneficiaryRegID
+    JOIN db_identity.i_beneficiarydetails bd 
+        ON bd.beneficiaryDetailsId = bm.BenDetailsId
+    WHERE ibd.BeneficiaryId IN :benIds
+    """, nativeQuery = true)
+    List<Object[]> findBenNamesByBenIds(@Param("benIds") List<Long> benIds);
 }
diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveActivityLangMappingRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveActivityLangMappingRepo.java
index f9807010..5a00844a 100644
--- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveActivityLangMappingRepo.java
+++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveActivityLangMappingRepo.java
@@ -8,4 +8,7 @@
 
 public interface IncentiveActivityLangMappingRepo extends JpaRepository<IncentiveActivityLangMapping, Long> {
     IncentiveActivityLangMapping findByIdAndName(Long activityId,String activityName);
+    List<IncentiveActivityLangMapping> findAllByIdIn(List<Long> ids);
+
+
 }
diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java
index 112f74ef..66c33b2f 100644
--- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java
+++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java
@@ -2,6 +2,7 @@
 
 
 import com.iemr.flw.domain.iemr.IncentiveActivity;
+import com.iemr.flw.domain.iemr.IncentiveActivityLangMapping;
 import com.iemr.flw.domain.iemr.IncentiveActivityRecord;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
@@ -10,6 +11,7 @@
 
 import java.sql.Timestamp;
 import java.util.List;
+import java.util.Set;
 
 @Repository
 public interface IncentivesRepo extends JpaRepository<IncentiveActivity, Long> {
@@ -28,4 +30,12 @@ IncentiveActivity findIncentiveMasterById(
 
     @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId")
     IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId);
-}
+
+    List<IncentiveActivity> findByGroupAndIsDeleted(String group, Boolean isDeleted);
+
+    List<IncentiveActivity> findByGroupNotAndIsDeleted(String group, Boolean isDeleted);
+
+    // IncentivesRepo — replaces N calls to findIncentiveMasterById()
+    @Query("SELECT i.id FROM IncentiveActivity i WHERE i.id IN :ids AND i.isDeleted = false AND " +
+            "(:isCG = true AND i.group = 'ACTIVITY' OR :isCG = false AND i.group != 'ACTIVITY')")
+    Set<Long> findValidActivityIds(@Param("ids") List<Long> ids, @Param("isCG") boolean isCG);}
diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java
index a590b016..4a1bd5ee 100644
--- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java
+++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java
@@ -421,19 +421,11 @@ private String getMappingsForAddressIDs(List<RMNCHMBeneficiaryaddress> addressLi
                         fetchHealthIdByBenRegID(m.getBenRegId().longValue(), authorisation, resultMap);
                     }
                     if(benDetailsRMNCH_OBJ.getIsChildrenAdded()!=null){
-                        if(benDetailsRMNCH_OBJ.getDoYouHavechildren()){
-                            if(benDetailsRMNCH_OBJ.getNoOfchildren()==0 && benDetailsRMNCH_OBJ.getNoofAlivechildren()==1){
-                                IncentiveActivity activity2 =
-                                        incentivesRepo.findIncentiveMasterByNameAndGroup("FP_DELAY_2Y", GroupName.FAMILY_PLANNING.getDisplayName());
-                                createIncentiveRecord(benDetailsRMNCH_OBJ, activity2);
-                            }
-
-                            if(benDetailsRMNCH_OBJ.getNoOfchildren()==1 && benDetailsRMNCH_OBJ.getNoofAlivechildren()==2){
-                                IncentiveActivity activity2 =
-                                        incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", GroupName.FAMILY_PLANNING.getDisplayName());
-                                createIncentiveRecord(benDetailsRMNCH_OBJ, activity2);
+                        if(benDetailsRMNCH_OBJ.getDoYouHavechildren() ){
 
-                            }
+                            IncentiveActivity activity2 =
+                                    incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", GroupName.FAMILY_PLANNING.getDisplayName());
+                            createIncentiveRecord(benDetailsRMNCH_OBJ, activity2);
 
                         }
                     }
diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java
index a33f5078..a220a0d6 100644
--- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java
+++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java
@@ -756,6 +756,28 @@ private void checkAndAddOrdDistributionIncentive(List<OrsDistribution> orsDistri
 
     }
 
+    private void checkAndAddIFAIncentive(List<OrsDistribution> orsDistributionList) {
+        orsDistributionList.forEach(orsDistribution -> {
+            IncentiveActivity orsPacketActivityAM =
+                    incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.CHILD_HEALTH.getDisplayName());
+            IncentiveActivity orsPacketActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName());
+            if (orsPacketActivityAM != null) {
+                if (orsDistribution.getNumOrsPackets() != null) {
+                    createIncentiveRecordforOrsDistribution(orsDistribution, orsDistribution.getBeneficiaryId(), orsPacketActivityAM, userRepo.getUserNamedByUserId(orsDistribution.getUserId()), false);
+                }
+            }
+
+            if (orsPacketActivityCH != null) {
+                if (orsDistribution.getNumOrsPackets() != null) {
+                    createIncentiveRecordforOrsDistribution(orsDistribution, orsDistribution.getBeneficiaryId(), orsPacketActivityCH, userRepo.getUserNamedByUserId(orsDistribution.getUserId()), true);
+                }
+            }
+
+
+        });
+
+    }
+
     private void checkAndAddHbyncIncentives(List<HbycChildVisit> hbycList) {
         IncentiveActivity hbync15MonethVisitActivityCH =
                 incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", GroupName.ACTIVITY.getDisplayName());
@@ -836,96 +858,221 @@ private void checkAndAddHbncIncentives(List<HbncVisit> hbncVisits) {
 
     private void checkAndAddIncentives(List<ChildVaccination> vaccinationList) {
 
+        logger.info("checkAndAddIncentives started. Total vaccinations: {}", vaccinationList.size());
 
         vaccinationList.forEach(vaccination -> {
-            Long benId = beneficiaryRepo.getBenIdFromRegID(vaccination.getBeneficiaryRegId()).longValue();
-            Integer userId = userRepo.getUserIdByName(vaccination.getCreatedBy());
-            Integer stateId = userRepo.getUserRole(userId).get(0).getStateId();
-            Integer immunizationServiceId = getImmunizationServiceIdForVaccine(vaccination.getVaccineId().shortValue());
-            if (immunizationServiceId < 6) {
-                if (stateId != null && stateId.equals(StateCode.AM.getStateCode())) {
-                    IncentiveActivity immunizationActivityAM =
-                            incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_IMMUNIZATION_0_1", GroupName.IMMUNIZATION.getDisplayName());
 
-                    if (immunizationActivityAM != null && childVaccinationRepo.getFirstYearVaccineCountForBenId(vaccination.getBeneficiaryRegId())
-                            .equals(childVaccinationRepo.getFirstYearVaccineCount())) {
+            try {
 
-                        createIncentiveRecord(vaccination, benId, userId, immunizationActivityAM);
-                    }
+                logger.info("Processing vaccinationId: {}", vaccination.getId());
 
+                // -------- USER FETCH --------
+                Integer userId = userRepo.getUserIdByName(vaccination.getCreatedBy());
+                logger.info("Fetched userId: {}", userId);
 
+                if (userId == null) {
+                    logger.error("UserId not found for createdBy: {}", vaccination.getCreatedBy());
+                    return;
                 }
-                if (stateId != null && stateId.equals(StateCode.CG.getStateCode())) {
-                    IncentiveActivity immunizationActivityCH =
-                            incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_IMMUNIZATION_0_1", GroupName.ACTIVITY.getDisplayName());
 
+                List<UserServiceRoleDTO> roles = userRepo.getUserRole(userId);
 
-                    if (immunizationActivityCH != null && childVaccinationRepo.getFirstYearVaccineCountForBenId(vaccination.getBeneficiaryRegId())
-                            .equals(childVaccinationRepo.getFirstYearVaccineCount())) {
-                        createIncentiveRecord(vaccination, benId, userId, immunizationActivityCH);
-                    }
+                if (roles == null || roles.isEmpty()) {
+                    logger.error("UserRole not found for userId: {}", userId);
+                    return;
                 }
 
+                Integer stateId = roles.get(0).getStateId();
+                logger.info("StateId: {}", stateId);
+
+                // -------- BENEFICIARY REG ID --------
+                Long regId = vaccination.getBeneficiaryRegId();
+
+                if (regId == null) {
+                    logger.error("BeneficiaryRegId is null for vaccinationId: {}", vaccination.getId());
+                    return;
+                }
+
+                logger.info("BeneficiaryRegId: {}", regId);
+
+                // -------- BEN ID FETCH --------
+                BigInteger benIdObj = beneficiaryRepo.getBenIdFromRegID(regId);
+
+                if (benIdObj == null) {
+                    logger.error("BenId not found for BeneficiaryRegId: {}", regId);
+                    return;
+                }
+
+                Long benId = benIdObj.longValue();
+                logger.info("BenId fetched: {}", benId);
+
+                // -------- VACCINE ID --------
+                if (vaccination.getVaccineId() == null) {
+                    logger.error("VaccineId is null for vaccinationId: {}", vaccination.getId());
+                    return;
+                }
+
+                Integer immunizationServiceId =
+                        getImmunizationServiceIdForVaccine(vaccination.getVaccineId().shortValue());
+
+                logger.info("ImmunizationServiceId: {}", immunizationServiceId);
+
+                // -------- GROUP NAME --------
+                String groupName = null;
 
-            } else if (immunizationServiceId == 7) {
                 if (stateId != null && stateId.equals(StateCode.AM.getStateCode())) {
-                    IncentiveActivity immunizationActivity2AM =
-                            incentivesRepo.findIncentiveMasterByNameAndGroup("COMPLETE_IMMUNIZATION_1_2", GroupName.IMMUNIZATION.getDisplayName());
-                    if (immunizationActivity2AM != null && childVaccinationRepo.getSecondYearVaccineCountForBenId(vaccination.getBeneficiaryRegId())
-                            .equals(childVaccinationRepo.getSecondYearVaccineCount())) {
-                        createIncentiveRecord(vaccination, benId, userId, immunizationActivity2AM);
-                    }
+                    groupName = GroupName.IMMUNIZATION.getDisplayName();
+                }
+                else if (stateId != null && stateId.equals(StateCode.CG.getStateCode())) {
+                    groupName = GroupName.ACTIVITY.getDisplayName();
+                }
+
+                logger.info("GroupName: {}", groupName);
+
+                if (groupName == null) {
+                    logger.warn("GroupName not found for stateId: {}", stateId);
+                    return;
                 }
 
-                if (stateId != null && stateId.equals(StateCode.CG.getStateCode())) {
-                    IncentiveActivity immunizationActivity2CH =
-                            incentivesRepo.findIncentiveMasterByNameAndGroup("COMPLETE_IMMUNIZATION_1_2", GroupName.ACTIVITY.getDisplayName());
-                    if (immunizationActivity2CH != null && childVaccinationRepo.getSecondYearVaccineCountForBenId(vaccination.getBeneficiaryRegId())
-                            .equals(childVaccinationRepo.getSecondYearVaccineCount())) {
-                        createIncentiveRecord(vaccination, benId, userId, immunizationActivity2CH);
+                // -------- FIRST YEAR IMMUNIZATION --------
+                if (immunizationServiceId != null && immunizationServiceId < 6) {
+
+                    logger.info("Checking FIRST YEAR IMMUNIZATION");
+
+                    IncentiveActivity activity =
+                            incentivesRepo.findIncentiveMasterByNameAndGroup(
+                                    "FULL_IMMUNIZATION_0_1",
+                                    GroupName.IMMUNIZATION.getDisplayName());
+
+                    logger.info("Activity fetched: {}", activity);
+
+                    if (activity != null) {
+
+                        Integer completedCount =
+                                childVaccinationRepo.getFirstYearVaccineCountForBenId(regId);
+
+                        Integer requiredCount =
+                                childVaccinationRepo.getFirstYearVaccineCount();
+
+                        logger.info("CompletedCount: {}, RequiredCount: {}", completedCount, requiredCount);
+
+                        if (completedCount != null && requiredCount != null
+                                && completedCount.equals(4)) {
+
+                            logger.info("First year immunization completed. Creating incentive.");
+
+                            createIncentiveRecord(vaccination, benId, userId, activity);
+                        }
                     }
                 }
 
+                // -------- SECOND YEAR IMMUNIZATION --------
+                else if (immunizationServiceId != null && immunizationServiceId == 7) {
 
-            }
-            if (stateId != null && stateId.equals(StateCode.AM.getStateCode())) {
-                IncentiveActivity immunizationActivity5AM =
-                        incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.IMMUNIZATION.getDisplayName());
-                if (immunizationActivity5AM != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) {
-                    createIncentiveRecord(vaccination, benId, userId, immunizationActivity5AM);
+                    logger.info("Checking SECOND YEAR IMMUNIZATION");
+
+                    IncentiveActivity activity =
+                            incentivesRepo.findIncentiveMasterByNameAndGroup(
+                                    "COMPLETE_IMMUNIZATION_1_2",
+                                    GroupName.IMMUNIZATION.getDisplayName());
+
+                    logger.info("Activity fetched: {}", activity);
+
+                    if (activity != null) {
+
+                        Integer completedCount =
+                                childVaccinationRepo.getSecondYearVaccineCountForBenId(regId);
+
+                        Integer requiredCount =
+                                childVaccinationRepo.getSecondYearVaccineCount();
+
+                        logger.info("CompletedCount: {}, RequiredCount: {}", completedCount, requiredCount);
+
+                        if (completedCount != null && requiredCount != null
+                                && completedCount.equals(3)) {
+
+                            logger.info("Second year immunization completed. Creating incentive.");
+
+                            createIncentiveRecord(vaccination, benId, userId, activity);
+                        }
+                    }
                 }
 
-            }
-            if (stateId != null && stateId.equals(StateCode.CG.getStateCode())) {
+                // -------- DPT 5 YEAR IMMUNIZATION --------
+                logger.info("Checking DPT 5 year immunization");
+
+                IncentiveActivity dptActivity =
+                        incentivesRepo.findIncentiveMasterByNameAndGroup(
+                                "DPT_IMMUNIZATION_5_YEARS",
+                                groupName);
+
+                if (dptActivity != null) {
+
+                    Integer vaccinated =
+                            childVaccinationRepo.checkDptVaccinatedUser(regId);
 
-                IncentiveActivity immunizationActivity5CH =
-                        incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.ACTIVITY.getDisplayName());
-                if (immunizationActivity5CH != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) {
-                    createIncentiveRecord(vaccination, benId, userId, immunizationActivity5CH);
+                    logger.info("DPT vaccinated result: {}", vaccinated);
+
+                    if (vaccinated != null && vaccinated == 1) {
+
+                        logger.info("DPT vaccine completed. Creating incentive.");
+
+                        createIncentiveRecord(vaccination, benId, userId, dptActivity);
+                    }
                 }
+
+            } catch (Exception e) {
+                e.printStackTrace();
+                logger.error("Error processing vaccinationId: {}", vaccination.getId(), e);
             }
 
         });
+
+        logger.info("checkAndAddIncentives completed.");
     }
+    private void createIncentiveRecord(ChildVaccination vaccination, Long benId, Integer userId,
+                                       IncentiveActivity immunizationActivity) {
+        try {
+            // null check
+            if (benId == null) {
+                logger.error("BeneficiaryRegId is null for vaccinationId: {}", vaccination.getId());
+                return;
+            }
+
+
+            IncentiveActivityRecord record = recordRepo
+                    .findRecordByActivityIdCreatedDateBenId(
+                            immunizationActivity.getId(),
+                            vaccination.getCreatedDate(),
+                            benId
+                    );
+
+            if (record == null) {
+
+                record = new IncentiveActivityRecord();
+                record.setActivityId(immunizationActivity.getId());
+                record.setCreatedDate(vaccination.getCreatedDate());
+                record.setCreatedBy(vaccination.getCreatedBy());
+                record.setStartDate(vaccination.getCreatedDate());
+                record.setEndDate(vaccination.getCreatedDate());
+                record.setUpdatedDate(vaccination.getCreatedDate());
+                record.setUpdatedBy(vaccination.getCreatedBy());
+                record.setBenId(benId);
+                record.setAshaId(userId);
+                record.setAmount(Long.valueOf(immunizationActivity.getRate()));
+
+                recordRepo.save(record);
+
+                logger.info("Incentive record created for BenId: {}", benId);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            logger.info("Incentive exception", e);
 
-    private void createIncentiveRecord(ChildVaccination vaccination, Long benId, Integer userId, IncentiveActivity immunizationActivity) {
-        IncentiveActivityRecord record = recordRepo
-                .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), vaccination.getCreatedDate(), benId);
 
-        if (record == null) {
-            record = new IncentiveActivityRecord();
-            record.setActivityId(immunizationActivity.getId());
-            record.setCreatedDate(vaccination.getCreatedDate());
-            record.setCreatedBy(vaccination.getCreatedBy());
-            record.setStartDate(vaccination.getCreatedDate());
-            record.setEndDate(vaccination.getCreatedDate());
-            record.setUpdatedDate(vaccination.getCreatedDate());
-            record.setUpdatedBy(vaccination.getCreatedBy());
-            record.setBenId(benId);
-            record.setAshaId(userId);
-            record.setAmount(Long.valueOf(immunizationActivity.getRate()));
-            recordRepo.save(record);
         }
+
+
     }
 
     private void createIncentiveRecordforHbncVisit(HbncVisit hbncVisit, Long benId, IncentiveActivity immunizationActivity, String activityName) {
diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java
index d759edc6..fe4c3912 100644
--- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java
+++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java
@@ -29,6 +29,7 @@
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Service
@@ -98,115 +99,147 @@ public String saveIncentivesMaster(List<IncentiveActivityDTO> activityDTOS) {
     @Override
     public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) {
         try {
+            Integer stateCode = incentiveRequestDTO.getState();
+            String langCode = incentiveRequestDTO.getLangCode();
 
-            List<IncentiveActivity> incs = new ArrayList<>();
-            if (incentiveRequestDTO.getState() == StateCode.CG.getStateCode()) {
-                incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList());
+            // Integer comparison using intValue() — safe and reliable
+            boolean isCG = stateCode != null && stateCode.intValue() == StateCode.CG.getStateCode();
+            boolean isAM = stateCode != null && stateCode.intValue() == StateCode.AM.getStateCode();
 
-            } else {
-                incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> !incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList());
+            // Single filtered DB query instead of findAll() + stream filter
+            List<IncentiveActivity> incs = isCG
+                    ? incentivesRepo.findByGroupAndIsDeleted("ACTIVITY", false)
+                    : incentivesRepo.findByGroupNotAndIsDeleted("ACTIVITY", false);
 
+            if (incs.isEmpty()) {
+                return new Gson().toJson(Collections.emptyList());
             }
-            List<IncentiveActivityDTO> dtos = incs.stream().map(inc -> {
-                IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class);
 
-                // Fetch language mapping
-                IncentiveActivityLangMapping mapping = incentiveActivityLangMappingRepo
-                        .findByIdAndName(inc.getId(), inc.getName());
+            // Fetch ALL lang mappings in ONE query instead of N queries in loop
+            List<Long> ids = incs.stream()
+                    .map(IncentiveActivity::getId)
+                    .collect(Collectors.toList());
 
+            Map<Long, IncentiveActivityLangMapping> mappingById = incentiveActivityLangMappingRepo
+                    .findAllByIdIn(ids)
+                    .stream()
+                    .collect(Collectors.toMap(
+                            IncentiveActivityLangMapping::getId,
+                            Function.identity()
+                    ));
+
+            List<IncentiveActivityDTO> dtos = incs.stream().map(inc -> {
+                IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class);
+                IncentiveActivityLangMapping mapping = mappingById.get(inc.getId());
 
                 if (mapping != null) {
                     dto.setName(mapping.getName());
-                    if(incentiveRequestDTO.getState().equals(StateCode.CG.getStateCode())){
-                        dto.setGroupName("");
 
-                    }
-                    if(incentiveRequestDTO.getState().equals(StateCode.AM.getStateCode())){
+                    if (isCG) {
+                        dto.setGroupName("");
+                    } else if (isAM) {
                         dto.setGroupName(mapping.getGroup());
-
                     }
 
-                    if (Objects.equals(incentiveRequestDTO.getLangCode(), "en")) {
-                        dto.setDescription(inc.getDescription());
-
-
-                    } else if (Objects.equals(incentiveRequestDTO.getLangCode(), "as")) {
-
-                        if (mapping.getAssameActivityDescription() != null) {
-                            dto.setDescription(mapping.getAssameActivityDescription());
-
-                        } else {
-                            dto.setDescription(mapping.getDescription());
-
-                        }
-
-                    } else if (Objects.equals(incentiveRequestDTO.getLangCode(), "hi")) {
-                        if (mapping.getHindiActivityDescription() != null) {
-                            dto.setDescription(mapping.getHindiActivityDescription());
+                    // Set description based on language
+                    if ("as".equals(langCode)) {
+                        dto.setDescription(mapping.getAssameActivityDescription() != null
+                                ? mapping.getAssameActivityDescription()
+                                : mapping.getDescription());
 
-                        } else {
-                            dto.setDescription(mapping.getDescription());
-
-                        }
+                    } else if ("hi".equals(langCode)) {
+                        dto.setDescription(mapping.getHindiActivityDescription() != null
+                                ? mapping.getHindiActivityDescription()
+                                : mapping.getDescription());
 
+                    } else {
+                        // default "en"
+                        dto.setDescription(inc.getDescription());
                     }
 
                 } else {
                     dto.setGroupName(inc.getGroup());
-
                 }
 
                 return dto;
             }).collect(Collectors.toList());
 
             Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create();
-
             return gson.toJson(dtos);
+
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("Error in getIncentiveMaster: ", e);
         }
         return null;
-
     }
 
     @Override
     public String getAllIncentivesByUserId(GetBenRequestHandler request) {
 
-        if (request.getVillageID() != StateCode.CG.getStateCode()) {
+        Integer villageID = request.getVillageID();
+        boolean isCG = villageID != null && villageID.intValue() == StateCode.CG.getStateCode();
+
+        if (!isCG) {
             checkMonthlyAshaIncentive(request.getAshaId());
         }
 
-        List<IncentiveRecordDTO> dtos = new ArrayList<>();
+        // Step 1: Fetch all records for this ASHA
         List<IncentiveActivityRecord> entities = recordRepo.findRecordsByAsha(request.getAshaId());
-        if (request.getVillageID() == StateCode.CG.getStateCode()) {
-            entities = entities.stream().filter(entitie -> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(), true) != null).collect(Collectors.toList());
 
-        } else {
-            entities = entities.stream().filter(entitie -> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(), false) != null).collect(Collectors.toList());
+        if (entities.isEmpty()) {
+            return new Gson().toJson(Collections.emptyList());
+        }
 
+        // Step 2: Collect all activityIds — fetch valid ones in ONE query
+        List<Long> activityIds = entities.stream()
+                .map(IncentiveActivityRecord::getActivityId)
+                .distinct()
+                .collect(Collectors.toList());
+
+        // Single bulk query instead of N individual findIncentiveMasterById() calls
+        Set<Long> validActivityIds = isCG
+                ? incentivesRepo.findValidActivityIds(activityIds, true)
+                : incentivesRepo.findValidActivityIds(activityIds, false);
+
+        // Filter entities based on valid activity IDs
+        entities = entities.stream()
+                .filter(e -> validActivityIds.contains(e.getActivityId()))
+                .collect(Collectors.toList());
+
+        // Step 3: Collect all benIds that need name lookup (name == null and benId > 0)
+        List<Long> benIdsToFetch = entities.stream()
+                .filter(e -> e.getName() == null && e.getBenId() != null && e.getBenId() > 0)
+                .map(IncentiveActivityRecord::getBenId)
+                .distinct()
+                .collect(Collectors.toList());
+
+        // Step 4: Bulk fetch all beneficiary names in ONE query instead of 3 queries per record
+        Map<Long, String> benIdToNameMap = new HashMap<>();
+        if (!benIdsToFetch.isEmpty()) {
+            List<Object[]> benDetails = beneficiaryRepo.findBenNamesByBenIds(benIdsToFetch);
+            for (Object[] row : benDetails) {
+                Long benId    = ((Number) row[0]).longValue();
+                String first  = row[1] != null ? (String) row[1] : "";
+                String last   = row[2] != null ? (String) row[2] : "";
+                benIdToNameMap.put(benId, (first + " " + last).trim());
+            }
         }
-        entities.forEach(entry -> {
+
+        // Step 5: Map entities to DTOs
+        List<IncentiveRecordDTO> dtos = entities.stream().map(entry -> {
             if (entry.getName() == null) {
-                if (entry.getBenId() != 0 && entry.getBenId() > 0L) {
-                    Long regId = beneficiaryRepo.getBenRegIdFromBenId(entry.getBenId());
-                    BigInteger benDetailId = beneficiaryRepo.findByBenRegIdFromMapping(BigInteger.valueOf(regId)).getBenDetailsId();
-                    RMNCHMBeneficiarydetail rmnchBeneficiaryDetails = beneficiaryRepo.findByBeneficiaryDetailsId(benDetailId);
-                    String beneName = rmnchBeneficiaryDetails.getFirstName() + " " + rmnchBeneficiaryDetails.getLastName();
-                    if(request.getVillageID().equals(StateCode.CG.getStateCode())){
+                if (entry.getBenId() != null && entry.getBenId() > 0) {
+                    String name = benIdToNameMap.getOrDefault(entry.getBenId(), "");
+                    entry.setName(name);
+                    if (isCG) {
                         entry.setIsEligible(true);
                     }
-                    entry.setName(beneName);
-
                 } else {
                     entry.setName("");
-
                 }
-
             }
-
-            dtos.add(modelMapper.map(entry, IncentiveRecordDTO.class));
-
-        });
+            return modelMapper.map(entry, IncentiveRecordDTO.class);
+        }).collect(Collectors.toList());
 
         Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create();
         return gson.toJson(dtos);
