added matching algorithm in .js