move scatter simulation to its own function