adding in the -d setting
Refactoring after criticism.