refactored codeCmp and BSTInsert