Adding preorder code