Rewrote the function which generates the dimension tables