move scroll target into a function