added slider switch click functionality and refactored code