refactored logging