Added function readState()