Added global state behaviour without using state - probably still some optimisation left