code for snapshot management