replace recursion with stack