changed adaptive algorithm; fixed scrollbar bug