Split update_tables into two methods and clean up the html creation