Revise code for real & sim data