fix bug and prepare snapshot function
add simple snapshot machenism and recover