Improve nearest match performance