Getting the tables sorted