rewrite ng simulator to a better internal data structure