I think the camera and transform stuff can still be placed inside the if block.  The dirty stuff needs to be outside, however.