Fixed the 'Cannot read property 'style' of null' error