Added -d option and revert process in case of failure