Fixed the issue where if a lesson was deleted, then it would cause errors in finding the next lesson