refactoring, added auto scroll functionality