changd way persist method functions and added write (incomplete)