tile.js refactoring