create helper function for running simulation