Modified script to include a topics table and a topic lookup table