fix the match implementation