refactoring and jiggery pokery