Fix to work with new database structure