added additional arguments to self invoking function to prevent 'window' and 'undefined' from being overwritten