change preorder to stack