improve algo with more ray-shooting