fixed entities matching cases while supporting old and new codes