rewrote pageload detector