#vulnerable code 
                                void initiateMigration() {
        for (int i = 0; i < BLOCK_COUNT; i++) {
            Block block = blocks[i];
            if (block == null) {
                block = concurrentMapManager.getOrCreateBlock(i);
                block.setOwner(thisAddress);
            }
        }
        if (concurrentMapManager.getMembers().size() < 2) {
            return;
        }
        if (lsBlocksToMigrate.size() == 0) {
            reArrangeBlocks();
        }
        if (lsBlocksToMigrate.size() > 0) {
            Block block = lsBlocksToMigrate.remove(0);
            if (concurrentMapManager.isBlockInfoValid(block)) {
                if (thisAddress.equals(block.getOwner())) {
                    concurrentMapManager.doBlockInfo(block);
                } else {
                    concurrentMapManager.sendBlockInfo(block, block.getOwner());
                }
            }
        }
    } 
                            #location 18 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                void reArrangeBlocks() {
        if (concurrentMapManager.isMaster()) {
            Map<Address, Integer> addressBlocks = getCurrentMemberBlocks();
            if (addressBlocks.size() == 0) {
                return;
            }
            List<Block> lsBlocksToRedistribute = new ArrayList<Block>();
            int aveBlockOwnCount = BLOCK_COUNT / (addressBlocks.size());
            for (Block blockReal : blocks) {
                if (blockReal.getOwner() == null) {
                    logger.log(Level.SEVERE, "Master cannot have null block owner " + blockReal);
                    return;
                }
                if (blockReal.isMigrating()) {
                    logger.log(Level.SEVERE, "Cannot have migrating block " + blockReal);
                    return;
                }
                Integer countInt = addressBlocks.get(blockReal.getOwner());
                int count = (countInt == null) ? 0 : countInt;
                if (count >= aveBlockOwnCount) {
                    lsBlocksToRedistribute.add(new Block(blockReal));
                } else {
                    addressBlocks.put(blockReal.getOwner(), ++count);
                }
            }
            Collection<Address> allAddress = addressBlocks.keySet();
            lsBlocksToMigrate.clear();
            for (Address address : allAddress) {
                Integer countInt = addressBlocks.get(address);
                int count = (countInt == null) ? 0 : countInt;
                while (count < aveBlockOwnCount && lsBlocksToRedistribute.size() > 0) {
                    Block blockToMigrate = lsBlocksToRedistribute.remove(0);
                    if (!blockToMigrate.getOwner().equals(address)) {
                        blockToMigrate.setMigrationAddress(address);
                        lsBlocksToMigrate.add(blockToMigrate);
                    }
                    count++;
                }
            }
            Collections.shuffle(lsBlocksToMigrate);
        }
    }