refactoring model for json
more javascript changes for saving