Updated to use primary key for Type lookup