Please read this post How to share code or flow json and edit your post to fix the formatting of the code you've shared.
Can you also explain in more detail what behaviour you want? We can't reverse engineer 50+ lines of code and guess what you want it to do.