Modify core data save function