Improved match rule for id and class