refactoring and better closest centerpoint matching