Tweaking of scrollIntoView function and small refactor