I think this logic is complex enough to warrant a comment describing what its intention is. 

I think this looks good, though.