Changed matching logic according to new file/database structure