Updated query and simulation script