Refactoring

Put row production in function