clean up match function