slider script refactor