Fix bug: check to ensure the parent course is in the $reference_courses array before attempting to access a specific array index.