Split into matching.R
Source code refactoring