Help with code for Midi legato playing and pitchbend

Something like this maybe?

uint8_t otherNotesPlaying = 0;
bool note62playing = false;

void MyHandleNoteOn(byte channel, byte pitch, byte velocity) { 
  if(pitch == 62)
    note62playing = true;
  else
    otherNotesPlaying++;
  if (note62playing && otherNotesPlaying == 0)
    MIDI.sendPitchBend(-2949,channel);
  else 
    MIDI.sendPitchBend(0,channel);
}

void MyHandleNoteOff(byte channel, byte pitch, byte velocity) { 
 if(pitch == 62)
    note62playing = false;
  else
    otherNotesPlaying--;
  if (note62playing && otherNotesPlaying == 0)
    MIDI.sendPitchBend(-2949,channel);
  else 
    MIDI.sendPitchBend(0,channel);
}