worked on save function