logic works for saving