Updated for the new database schema