refactoring and scaling up simulations