Declare your variables outside the function and give them different names. Then inside the functions you can access and change them. And the last function will work just fine.
Just remember to use different names
solved how to extract a variable inside a function and put in another function