a bit of refactoring to use a generic table where appropriate