made script more modular and it now accepts target directory
Merge branch 'v1' into v2
Merge branch 'v2' into v3
made script more modular and it now accepts target directory