a bit more optimization to the inorder efficient method.