added functional implementation of BST