optimize runZHanalysis code