Refactor for readability, add --dry-run option