integrated Andrew's fix for STOP(t) trials