I have no idea what this "image_for_tab" is. But since it is checking class instances, I wonder if it should be pushed into the page classes as a property.