fixed bugs in state rep