revised BST to be general purpose