correctly calculate cutoff
space and backspace to scroll
reduce len() calls