Added logic to trace back the ball from point B to point A