improved efficiency of binary recursion