added debug mode option