refactor to use new table definitions