refactor python