TODO: — add a function to stop calculating the path