Refactored and added a special case for Error logging