fixed Cannot read property 'document' of null error issue.