Could you move this entire if block to a new private method?