added findMatch function to javascript