State variables implemented. TODO update function