replaced the method for building the tables