added debug mode and new option