fixed tiedNotesFix function to work more generally