whitespace nit
faster history handling
factor binary search out