OK, so why not debug the function if this is how easy it is to duplicate the error? You told us it crashes on a line in the function, but why not debug the code to determine where things start going...