fixes issue when document.head is null