extract match function