Monte carlo, refactoring