Refactored 147d9f6 for better structure