Please see the post below for how to share flows here, the one you posted is not importable. However before doing that you say that it is just one function that is not working. Start by putting a debug node showing what is going into the function and check that is correct. Next you can insert node.warn() statements into your code to show the state of variables as it runs through. The warn text will be shown in the debug pane. If that does not help then post just the function here and show us what is going into it.