partway through refactoring to use models and psql