add conditional logging