1st version of the match function