changed unload handler form window to document
removed empty lines