optimize effeciency of scroll listener