Refactoring
Write messages to log