Wrapped $cur with double quotes whenever it is passed as an argument in calling a function defined within the file.
When $cur was null this was causing issues when the argument was referenced within a function. Passing it as "$cur" will turn it into an empty string.