fixed problem with static variables messing up recursion
merge