added conditional logging