dirty implementation of matchdict