It makes it a little harder to see at a glance what's going on with the key-swap, though... I feel more concerned about that than saving bytes or cycles here.  I can move the `var doc` initialization up to the top though, if you want.