added function for scroll event