fix "TypeError: Cannot read property 'off' of null"