moved array declarations outisde of the recursion function for speed.