Why not try this with skript?
Yeah, I don't wanna be that guy who says for every plugin suggestion "just do this in skript" however, this can be done in skript easily. Example: https://srcb.in/PtUNdrASnh