refactor sliding tile JS