partial implementation of match functions

problem: performance may not be efficient — 4 nested for loop may not
be good idea. Need to find a better way to perform this if we need to
take care of scalability
Merge pull request #1 from intoxicated/master

partial implementation of match functions