Got any tips for using sustain pedal playing chords + melody?

I often catch the release note with the sustain pedal, right now I try to instantly mute chords with my right hand after pressing down the pedal, but it still can get pretty muddy.
How do you use the pedal if you try to sustain notes on the same string without it catching the notes in between?
Example:

Me playing:

1 Like