logging functionality partially implemented. refactored