Fixing the toggling of the pan button