modified persist code