Tweak call to Function.apply to pass null instead of window, I think it's clearer bizarelly