refactor rest store (still not complete)