added log output logic