refactor python simulator