done with refactoring the check on tables