not compiling, just put the global state as argument
global state

functions are now working on a global state, a function to create a
empty global state has been added
proper comments