Refactoring codeJam extension method