fixing some matching logic