Refactoring slide change directive