adding first version of save logic