implemented bruner's algorithm