fixed more match function bugs