Working on fixing the matching code