refactoring newwmatch js file.