add mkdirp,rmdir dependencies and refactor the logic