modify directory deletion sequence
Merge pull request #1926 from jainvipin/master

minor fix for #1786