reverted earlier 'window' to 'document' change