Refactored code for table model representation