added feature to storing state