function CombinationProduction_block(myWordClass, targetWord, targetWordTranslate, nounName, nounNameTranslate, imageName,
    production_text, task_type) {

    // myWordClass: ['Number Word', 'Class Word']
    // myWordTranslate: [['two','three'],['animate','inanimate']]
    // exposure_text: ['exposure text for Num','exposure text for Cl']
    // reps: repetitions for each of the four words (not each word class), so repetitions for each word class is 2*reps 
	var production_trials = [];
    var score = []; // initialise word class scores for data saving
    score[0] = 0;
    score[1] = 1;

    // set buttons (buttons for two words, the Reset button and Submit button)
    var wordButtonLeftPos = [43,49];
    var wordButtonTopPos = [69,69];
    var resetButtonLeftPos = 42.5;
    var resetButtonTopPos = 77.5;
    var submitButtonLeftPos = 49.5;
    var submitButtonTopPos = 77.5;
    // button properties for choices of words
    var buttonPropertyWords  = 'font-size:1em; font-weight:100; border:#ccc solid; border-radius:10px; border-width:0.12VW; width:5vw; height: 2.8vw;z-index:1';
    // a background disabled button was set to have a boundary to contain all three choices of words
    var backgroundButtonLeftPos = wordButtonLeftPos[0]-1.5;
    var backgroundButtonTopPos = wordButtonTopPos[0]-1.5;
    var buttonPropertyBackground = 'border:#ccc solid; border-radius:10px; border-width:0.12vw; width:14vw; height:4vw; z-index:2, pointer-events:none; background-color:transparent';
    var backgroundButton = '<button class="jspsych-btn" style="position:absolute;left:'+backgroundButtonLeftPos+'%;top:'+backgroundButtonTopPos+'%;'+buttonPropertyBackground+'" disabled="true"></button>';
    // button properties for Reset and Submit
    var buttonPropertyResetSubmit  = 'font-size:0.7em; font-weight:100; border:#ccc solid; border-radius:10px; border-width:0.12vw; width:5vw; height: 2vw; background-color:transparent';
    // buttons for Reset and Submit (abled + disabled)
    var reset_bt_abled = '<button class="jspsych-btn" style="position:absolute;left:'+resetButtonLeftPos+'%;top:'+resetButtonTopPos+'%;'+buttonPropertyResetSubmit+'">Reset</button>';
    var reset_bt_disabled = '<button class="jspsych-btn" style="position:absolute;left:'+resetButtonLeftPos+'%;top:'+resetButtonTopPos+'%;'+buttonPropertyResetSubmit+'" disabled="true">Reset</button>';
    var submit_bt_abled = '<button class="jspsych-btn" style="position:absolute;left:'+submitButtonLeftPos+'%;top:'+submitButtonTopPos+'%;'+buttonPropertyResetSubmit+'">Submit</button>';
    var submit_bt_disabled = '<button class="jspsych-btn" style="position:absolute;left:'+submitButtonLeftPos+'%;top:'+submitButtonTopPos+'%;'+buttonPropertyResetSubmit+'" disabled="true">Submit</button>';

    // set the feedback words
    var feedbackWord = ['Correct!','Incorrect!'];
    var feedbackPos = 'bottom6';
    var feedbackdur = 2000; // feedback duration of 2 seconds

    // randomise word button sequence
    var num_of_trials = targetWord.length;
    var if_consecutive_items = true;
    var max_num_consecutive_items = 2;
    while (if_consecutive_items == true){
        var buttonPosSeq = [];
        for (var t=0; t<num_of_trials; t++){
            buttonPosSeq[t] = shuffle([0,1]);
        }
        if_consecutive_items = if_consecutive(buttonPosSeq, max_num_consecutive_items+1);		
        // ensure that a same button sequence does not present more than twice consecutively
    };

    // ******* initiate trial number for each word class
    var trl_num_currWrdClss = [];
    for (var w=0; w<2; w++){
        trl_num_currWrdClss[w] = 1;
    }
    
    // randomise trial sequences
    var seq = range(0,100).slice(0,num_of_trials);
    var seq = shuffle(seq);

    // ******* construct the trials
    for (var t = 0; t < num_of_trials; t++) {

        var word_class_name = myWordClass[seq[t]]; // 'Number Word' or 'Class Word'
        var target_name = targetWord[seq[t]];
        var target_name_trnsl = targetWordTranslate[seq[t]];
        var noun_name = nounName[seq[t]];
        var noun_name_trnsl = nounNameTranslate[seq[t]];
        var image_name = imageName[seq[t]];
        var orientation = shuffle(['','']);
        orientation = orientation[0];
        if (word_class_name=='Number Word'){
            var wordClassID = 0;
        } else {
            var wordClassID = 1;
        }
        var trl_num_currWordClass = trl_num_currWrdClss[wordClassID]; // the trial number for the current word class (initial value is 0 and are added up by 1 every loop)
        trl_num_currWrdClss[wordClassID] += 1; // add 1 for trial number for each word class per loop 

        // assign images
        var image_blank = '<img src="'+img_path+"empty_image.png"+'" class="Cntr0" >';
        var image = [];
        image[0] = image_blank;
        image[1] = '<img src="'+img_path+image_name+orientation+'.jpg" class="Cntr0" >';

        // assign buttons for the words (noun and target)
        var btPosSeq = buttonPosSeq[t];
        var wordButton_abled = [];
        var wordButton_disabled = [];
        var wordContent = [noun_name,target_name];
        var wordContentTranslate = [noun_name_trnsl,target_name_trnsl];
        for (var w = 0; w < 2; w++) {
            wordButton_abled[w] = '<button class="jspsych-btn" style="position:absolute;left:'+wordButtonLeftPos[btPosSeq[w]]+
               '%;top:'+wordButtonTopPos[btPosSeq[w]]+'%;'+buttonPropertyWords+'">'+wordContent[w]+'</button>';
            wordButton_disabled[w] = '<button class="jspsych-btn" style="position:absolute;left:'+wordButtonLeftPos[btPosSeq[w]]+
               '%;top:'+wordButtonTopPos[btPosSeq[w]]+'%;'+buttonPropertyWords+'" disabled="true">'+wordContent[w]+'</button>';
        }
        
        production_trials.push({trl_num:t+1, trl_num_wrdclss:trl_num_currWordClass, wrd_clss:word_class_name, wrd_clss_id:wordClassID,
            target:target_name, target_trnsl:target_name_trnsl, noun:noun_name, noun_trnsl:noun_name_trnsl,
            img:image, img_blank:image_blank, ortt:orientation, wrd_content:wordContent, wrd_content_trnsl:wordContentTranslate,
            wrd_button_pos_seq:btPosSeq, wrd_button_abled:wordButton_abled, wrd_button_disabled:wordButton_disabled});
    }

	// for save csv
	var csv_header = ['','trial_overall','trial_wordClass','wordClass','orientation','testing_word','Translate',
        'testing_word_buttonPos','Noun','NounTranslate','Noun_buttonPos','ProducedPhrase','ProducedPhraseTranslate',
        'correctness','correctness_sum','correctness_percent (accumulative)','saveTime\n'];
	var data_to_save = csv_header;

    //// ******************* trial setup according to the randomised pairing *****************************
    var new_trial = true;
    var trial_loop_dur = 100000000;
    var selectedWords = [];
    var selectedWordsTranslate = [];
    var resp = null;
    var phrase = '';
    var phraseTranslate = '';
    var feedback = '';

    var show_image = {
        type: 'html-keyboard-response',
        stimulus: jsPsych.timelineVariable('img'), // calls image stimuli
        choices: jsPsych.NO_KEYS,
        prompt: function(){new_trial = true; return production_text},
        response_ends_trial: false,
        trial_duration: 800
    };

    var make_choice = {
        type: 'html-button-response',
        stimulus: jsPsych.timelineVariable('img'),
        prompt: function(){
            // *** ALWAYS keep the button choice sequence as [word1 (noun), word2 (Num/Cl), Reset, Submit]
            if (new_trial==true){ // initialise resp and selected words at the start of the trial
                resp=null; // seen from actual tests, this is actually not necessary...
                phrase='';
                phraseTranslate = '';
                trial_loop_dur = 100000000;
                feedback = '';
            }; 
            resp = jsPsych.data.get().last(1).values()[0].button_pressed // the last response
            if (trial_loop_dur==feedbackdur){trial_loop_dur=1}; // if feedback has been shown, set trial_loop_dur to minimum so the loop completes quickly
            var words = jsPsych.timelineVariable('wrd_content',true);
            var wordsTranslate = jsPsych.timelineVariable('wrd_content_trnsl',true);
            var nounName = jsPsych.timelineVariable('noun',true);
            if (resp<2&(resp!=null)) { // if word(s) are selected then show the words
                selectedWords = selectedWords.concat(words[resp]);
                selectedWordsTranslate = selectedWordsTranslate.concat(wordsTranslate[resp]);
                phrase = phrase + words[resp] + ' ';
                phraseTranslate = phraseTranslate + wordsTranslate[resp] + ' ';
                console.log(selectedWords)
                console.log(phrase)
                console.log(phraseTranslate)
            }
            if (resp==2) { // if Reset is pressed then empty the shown words
                selectedWords = [];
                selectedWordsTranslate = [];
                phrase = '';
                phraseTranslate = '';
            }
            if (resp==3) { // if Submit is pressed then show the words and feedback and save data
                if (selectedWords[0]==nounName) { // noun at the start which is correct
                    var correctness = 1;
                    feedback = feedbackWord[0];
                } else { // otherwise incorrect
                    var correctness = 0;
                    feedback = feedbackWord[1];
                }
                selectedWords = []; // set back to empty
                trial_loop_dur = feedbackdur;
                // ----------------------------- SAVE DATA (csv)------------------------------------
                var trl_num_overall = jsPsych.timelineVariable('trl_num',true);
                var trl_num_wordclass = jsPsych.timelineVariable('trl_num_wrdclss',true);
                var wordClass = jsPsych.timelineVariable('wrd_clss',true);
                var wordClassID = jsPsych.timelineVariable('wrd_clss_id',true);
                var targetName = jsPsych.timelineVariable('target',true);
                var targetNameTranslate = jsPsych.timelineVariable('target_trnsl',true);
                var nounNameTranslate = jsPsych.timelineVariable('noun_trnsl',true);
                var wordButtonPosSeq = jsPsych.timelineVariable('wrd_button_pos_seq',true);
                var nounPos;
                var targetPos;
                if (wordButtonPosSeq[0]==0){nounPos='left';targetPos='right'}else{nounPos='right';targetPos='left'}
                var orient = jsPsych.timelineVariable('ortt',true);
                if (orient==''){orient='NA'};
                score[wordClassID] = score[wordClassID] + correctness; // accumulative correctness
                var score_percent = score[wordClassID]/trl_num_wordclass*100; // accumulative correctness in percentage
                var time = getTime();
                var data_snglTrl = [trl_num_overall, trl_num_wordclass, wordClass, orient, targetName, targetNameTranslate, 
                          targetPos, nounName, nounNameTranslate, nounPos, phrase, phraseTranslate,
                          correctness, score[wordClassID], score_percent, time+'\n'];
                data_to_save = data_to_save.concat(data_snglTrl);
                // calculate overall correctness when finish all trials
                if (trl_num_overall==num_of_trials) {
                    var score_percent = [];
                    score_percent[0] = score[0]/(num_of_trials/2)*100; // overall average score convert to percentage
                    score_percent[1] = score[1]/(num_of_trials/2)*100; 
                    var score_summary = ['\n','overall_correctness_percent ('+myWordClass[0]+')',score_percent[0]+'\n',
                                         'overall_correctness_percent ('+myWordClass[1]+')',score_percent[1]+'\n'];
                    data_to_save = data_to_save.concat(score_summary);
                    // declare Combination Production summary as global for the subsequent final saving
					window.CmbPrd_summary = score_summary;
                }
                var data_to_save_string = data_to_save.toString();
                var csvName = window.saveFileNameHeader+'_'+task_type+'.csv';
                saveData(csvName,data_to_save_string);
                // ----------------------------- SAVE DATA (csv)-----------------------------------
            }
            phrase_on_screen = '<div class="bottom7"><strong>'+phrase+'</strong></div>';
            feedback_on_screen = '<div class="'+feedbackPos+'"><strong>'+feedback+'</strong></div>';
            var prompt_to_return = phrase_on_screen + production_text + feedback_on_screen;
            new_trial=false;
            return prompt_to_return
        },
		choices: function(){
            // *** Always keep the button choice sequence as [word1 (noun), word2 (Num/Cl), Reset, Submit]
            var bt_choice = [];
            var wrd_bt_abled = jsPsych.timelineVariable('wrd_button_abled',true);
            var wrd_bt_disabled = jsPsych.timelineVariable('wrd_button_disabled',true);
            resp = jsPsych.data.get().last(1).values()[0].button_pressed // the last response
            if (selectedWords.length<1) {// if there is no word is selected then set Reset and Submit buttons disabled
                bt_choice = [wrd_bt_abled[0],wrd_bt_abled[1],reset_bt_disabled,submit_bt_disabled];
            } else if (selectedWords.length==1) { // if there is one word is selected then set the selected words' button and Submit disabled but the non-selected word and Reset as abled
                if (resp==0){// if the selected word is the first word
                    bt_choice = [wrd_bt_disabled[0],wrd_bt_abled[1],reset_bt_abled,submit_bt_disabled];
                } else { // if the selected word is the second word
                    bt_choice = [wrd_bt_abled[0],wrd_bt_disabled[1],reset_bt_abled,submit_bt_disabled];
                }
            } else { // if there are two words selected then set both words' buttons disabled but both Reset and Submit buttons as abled
                bt_choice = [wrd_bt_disabled[0],wrd_bt_disabled[1],reset_bt_abled,submit_bt_abled];
            }
            if (trial_loop_dur<=feedbackdur){ // additionally if it is at feedback mode or later then disable all buttons
                bt_choice = [wrd_bt_disabled[0],wrd_bt_disabled[1],reset_bt_disabled,submit_bt_disabled];    
            }
            bt_choice = bt_choice.concat(backgroundButton);
            return bt_choice
        },    
        response_ends_trial: true,
        trial_duration: function(){return trial_loop_dur}
    }

    var blank_page = {
		type: 'html-keyboard-response',
		choices: jsPsych.NO_KEYS,
		stimulus: jsPsych.timelineVariable('img_blank'),
		trial_duration: 100
	    };

    var timeline_trials = [];
    timeline_trials.push(show_image)
    for (var n=0; n<100; n++) {timeline_trials.push(make_choice)};
    timeline_trials.push(blank_page);

	// put them together
	var production_trial = {
        timeline: timeline_trials,
        // add the trials as a variable
        timeline_variables: production_trials,
    };
 
 return production_trial

}