implement simulating function