refactored slider js