complete rewrite of the snapshoting algo