This function has a bit semi-duplicate if / else. The only difference was the reference to activate or deactivate, so I've pulled that out into a simpler conditional.