First use this way to format your code:
it is probably less work and is better readable as
> is for indented text not code.
should probably be choice2 even though that doesn't seem to be related to the error.
PS: Maybe the author was over thinking it and as he doesn't got the correct result from your code he anticipated that something is wrong with your function... Still not optimal.