refactor the construct function of the table class