merged version for simulation