refactoring js slider