added working snapshot code