change format to get right json string
add function getstate to deal with state info store in txt file
add function setstate to store  state info store in txt file
change code to suit erro ocu