fixed bug where detection would not start until web page accessed one time. Simplified code