re-write for the database model