refactored the db to fit the ORM style