addapted
moved snapshot handling into separate file