combined auto snapshot scripts into one using functions, some improvements