rem

remstate added
printstate modified
Need to test&refactor