more robust matching, no more crashing