added semicolon
replaced references to global window object with variable global
reorganized file and fixed code style