refactoring and improvements to tables