addedf snapshot function to R files