move logic into save() method