Refactor table generator