refactored logging, added switch