Just put this throw after the loop so it throws if it doesn't find a match. No need to check for getSections equaling null or the count not matching.