What about putting this logic on it's own line before the respond_for_index?