A comment about what this entire if block is doing would be welcome.