A sad attempt at refactoring