using reflection on tables, refactoring