Updated scroll function