refactoring binsetree