Added error handling for findNearestBetterSessionID