implement simulation function