1. Please post the calling statement (what you type on at the command prompt or have in the script file)
2. Consider executing in the debugger.
3. Look at all the red or amber marks to the right in the editor, each of these indicates a syntactical mistake or a warning that the code may not be doing what you think, so check them.
4. You appear to be calling the top level function recursively, I doubt you intend this.