Refactor data preparation in example.py