Implemented better recursion for nearby points and specify a max recursion depth