functions adjusted to new database model