fixing persist function