added autoscroll logic