Made the inorder functionality a bit more general