js code for combining trials for model building