working out how to deal with multiple tables