refactor sliding, much smaller