Added self invoking function + readability + bug fix

Also removed non used update function