add match algorithm (unfinished)