Continue cleaning up code for experiment

- move query generation outside the experiment loop.