restructuring and adding dry-run option for easy debuging