Implemented almost the functions of Match