I'd encapsulate all of this checking into a `itemAtIndexPath:` method. I see it repeated several times.