I want to call myfun1 only once with setInterval. I want to avoid using a global variable. Read [this](https://stackoverflow.com/questions/3332265/how-to-detect-a-function-was-called-with-javascript) but it does not work (just calls the function every 2000 ms). Naturally I need to call main() every 2000 ms.

```
(function($){         
    setinterval(main,2000);  

     function main (){            
        if(/*condition*/) return;

        function callItOnce(fn) {
            var called = false;
            return function() {
                if (!called) {
                    called = true;
                    return fn();
                }
                return;
            }
        }

        myfun1 = callITOnce(myfun1);
        myfun1();

        function myfun1(){/*code*/};
        function myfun2(){/*code*/};
        function myfun3(){/*code*/};
})(jquery);

```