turns out that state encoder/decoder is not working properly, TODO fix this!