adding preorder funcationality