reorganized and improved tiling