I know that this isn't your doing, but now that we have quite a bit of repeated code here, it seems like it would be better to pull this all out into a function to which we could pass the appropriate new light.