some refactoring, created table template