first part of saving to json