adds exception handling and moves duplicate code to helper function
adds exception handling and moves duplicate code to helper function

sitofabi/duplicati,mnaiman/duplicati,mnaiman/duplicati,sitofabi/duplicati,duplicati/duplicati,duplicati/duplicati,sitofabi/duplicati,mnaiman/duplicati,duplicati/duplicati,sitofabi/duplicati,mnaiman/duplicati,mnaiman/duplicati,sitofabi/duplicati,duplicati/duplicati,duplicati/duplicati